On May 21, 2014, at 12:52 PM, Tony Burns <
tabo...@gmail.com> wrote:
> I’ve actually gone through all of those except for the last one! One thing I’m left wondering with pgTAP right now is whether it’s good practice to use each matcher that might be appropriate for a given column for it’s test, e.g.
https://gist.github.com/tabolario/28e3d47195dad38d01b6. I certainly see how I would end up with all of them if I TDD each part of a column/table definition incrementally (i.e. failing test for col_not_null, add NOT NULL to column, repeat).
That’s how I do it. Though if you’re using xUnit functions, you don’t have to RETURN QUERY everything. You can just RETURN NEXT the functions directly:
RETURN NEXT has_column('users', 'id');
RETURN NEXT col_type_is('users', 'id', 'uuid');
RETURN NEXT col_is_pk('users', 'id');
RETURN NEXT col_default_is('users', 'id', 'uuid_generate_v4()');
If you like grouping things, you can also use collect_tap():
RETURN NEXT collect_tap(
has_column('users', 'id'),
col_type_is('users', 'id', 'uuid'),
col_is_pk('users', 'id'),
col_default_is('users', 'id', 'uuid_generate_v4()')
);
> All in all though I’m very happy that I found Sqitch, because up until now I’ve been more of an ActiveRecord programmer vs. a SQL programmer. I’m excited that this is going to force me to start writing more SQL!
Excellent, happy to hear it.
Best,
David