kevin
unread,Jul 31, 2024, 11:02:49 AM7/31/24Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to pgTAP Users
Has anyone considered doing a test like:
column_is(:schema, :table, :column, :type, :nullable,
:default_value, :check_value, :description)
The idea is to be able to test what is most commonly needed to verify a
column, which means we probably don't want the "check_value" because
CHECK isn't used as often as the others but I added it just because it
is part of a column. The default and check values could be NULL if they
aren't expected to exist. Anyway, it would combine:
has_schema /* required for qualification */
has_table /* required for qualification */
has_column
col_type_is -- string
col_is_null / col_not_null -- boolean -- true is nullable & false is
not null
col_has_default / col_default_is -- string or NULL
col_has_check / col_check_is -- string or NULL
The point is to make the test file less verbose by combining the last 5
lines in the list above into 1. Assuming the schema/table/column exists
(and it could abort if one of those is not true), then it's possible you
could get multiple diagnostics (of have/want) for a single test (and a
single pass/fail), and that might not be what is desired. I suppose that
boils down to should the tests be fine grained & testing individual
attributes, or can the tests be coarser grained by testing an entire
column at once.
To help remove potential confusion on the nullable column, it might be
best to create 2 constants called "Nullable" and "Notnullable" (or
"Notnull").
A co-worker and I came up with the idea recently when discussing testing
where I work and I thought I'd toss the idea here in case others find it
useful and someone wants to implement it. Or if this doesn't fit in with
the general Pgtap philosophy then the idea can be ignored.
Kevin