Welsh time travel

It’s nice being self employed so you can work where you like, but then it does open you up a bit to distraction… Today I went on a walk up past Llyn-Crafnant, which is near Betws-y-coed in North Wales. I managed to do a spot of work this morning, and I’m doing some more now, but the bank holiday Friday atmosphere has sucked me in a bit against my will. I’ve spent the week at a friend’s house in the country. Ben also works from home, and it has been a pleasant change having tea and excellent food cooked for me, and having walks with hills. There aren’t enough hills in Cambridge.

At the moment I’m improving the PledgeBank test suite. It’s a perl script which makes sure the PledgeBank code is working. An artificial browser clicks through links on my local development copy of the website, fills in forms to make new pledges, and to sign them. It also gets email, so it can follow confirmation links, and make sure the right messages arrive in the right circumstances. This is not just a good way of finding bugs, but extremely reassuring. Especially as I know we’ll have to change the site a lot as people start using it seriously.

Now, the problem with testing PledgeBank is that it depends on the passage of time. At the moment the test script gets the “pledge success” and “pledge failure” messages script to lie about which date it is, which tests that part. But that isn’t subtle enough, really the whole application including the website needs to bend in time. On my walk I finally worked out that I need to be able to override “today”, and that the best way to do this is with a function in the database which gets called whenever something wants the date.

So, that’s what I’m implementing right now.