home :: computers :: databases :: postgresql :: pgtap-0.12

pgTAP 0.12 Released

In anticipation of my PostgreSQL Conference West 2008 talk on Sunday, I’ve just released pgTAP 0.12. This is a minor release with just a few tweaks:

  • Updated plan() to disable warnings while it creates its tables. This means that plan() no longer send NOTICE messages when they run, although tests still might, depending on the setting of client_min_messages.
  • Added hasnt_table(), hasnt_view(), and hasnt_column().
  • Added hasnt_pk(), hasnt_fk(), col_isnt_pk(), and col_isnt_fk().
  • Added missing DROP statements to uninstall_pgtap.sql.in.

I also have an idea to add functions that return the server version number (and each of the version number parts) and an OS string, to make testing things on various versions of PostgreSQL and on various operating systems a lot simpler.

I think I’ll also spend some time in the next few weeks on an article explaing exactly what pgTAP is and why you’d want to use it. Provided, of course, I can find the tuits for that.

Comments & Trackbacks

Ben Finney wrote:

  • Added hasnt_table(), hasnt_view(), and hasnt_column().
  • Added hasnt_pk(), hasnt_fk()
  • […]

Those are grammatically awful in English. It helps, when naming a function, to use good grammar. Otherwise, the function won't be connected well with what the person tries to do, and thus won't be remembered properly.

Possible improvements (instead of hasnt_foo(bar)):

  • has_no_foo(bar)
  • doesnt_have_foo(bar)
  • not_has_foo(bar)

It's unfortunate that the English grammar of “has foo”/“doesn't have foo” isn't a nice fit to function names; but choosing poor names will just make your API harder to use.

Theory wrote:

On Grammar

Thanks for your comments, Ben. I actually gave this a bit of thought, being something of a grammar pedant myself, and decided that benefits of the semantic the balance between “has” and “hasnt” outweighed any possible grammatical confusion. After all, the has_ forms are quite natural (“I'm testing to make sure that this database has a certain table”), and while it didn't occur to me until afterwards to add the negated versions, to me testing with “hasnt” is close enough (“I'm testing to make sure that this table hasn't a certain table). It's a bit archaic, perhaps, but it works.

That said, has_noisn't bad; I hadn't thought of it, though if I had, I might have rejected it anyway, as I do try to keep such things to the same numbers of words (i.e., the same number of underscores). have, on the other hand, doesn't really work. I have, but the database has. I'm testing the database, not myself.

That's my perspective, anyway. I wanted the negated functions to be easy to remember and nicely complementary, without being too long or too weird. I think that has_ and hasnt_ do the trick.

Thanks for the comments, though; I really appreciate it when other folks take the time to think about this stuff, too! It shows you care! :-)

—Theory

Powered by KinoSearch