Skip to content

Commit

Permalink
Convertd sql/coltap.sql to use check_test().
Browse files Browse the repository at this point in the history
  • Loading branch information
theory committed Sep 23, 2008
1 parent 9d6a6c3 commit ca6fa97
Show file tree
Hide file tree
Showing 2 changed files with 160 additions and 133 deletions.
97 changes: 58 additions & 39 deletions expected/coltap.out
@@ -1,40 +1,59 @@
\unset ECHO
1..38
ok 1 - testing col_not_null( schema, table, column, desc )
ok 2 - col_not_null( schema, table, column, desc ) should work
ok 3 - testing col_not_null( table, column, desc )
ok 4 - col_not_null( table, column, desc ) should work
ok 5 - testing col_not_null( schema, table, column, desc )
ok 6 - col_not_null( table, column ) should work
ok 7 - testing col_not_null( schema, table, column, desc )
ok 8 - col_not_null( table, column ) should properly fail
ok 9 - testing col_is_null( schema, table, column, desc )
ok 10 - col_is_null( schema, table, column, desc ) should work
ok 11 - testing col_is_null( table, column, desc )
ok 12 - col_is_null( table, column, desc ) should work
ok 13 - testing col_is_null( schema, table, column, desc )
ok 14 - col_is_null( table, column ) should work
ok 15 - testing col_is_null( schema, table, column, desc )
ok 16 - col_is_null( table, column ) should properly fail
ok 17 - testing col_type_is( schema, table, column, type, desc )
ok 18 - col_type_is( schema, table, column, type, desc ) should work
ok 19 - testing col_type_is( table, column, type, desc )
ok 20 - col_type_is( table, column, type, desc ) should work
ok 21 - testing col_type_is( table, column, type )
ok 22 - col_type_is( table, column, type ) should work
ok 23 - testing col_type_is( table, column, type ) case-insensitively
ok 24 - col_type_is( table, column, type ) should work case-insensitively
ok 25 - testing col_type_is( table, column, type ) failure
ok 26 - col_type_is( table, column, type ) should fail with proper diagnostics
ok 27 - testing col_type_is( schema, table, column, type(precision,scale), description )
ok 28 - col_type_is( schema, table, column, type, precision(scale,description) should work
ok 29 - col_type_is( table, column, type, precision, desc ) fail
ok 30 - col_type_is with precision should have nice diagnostics
ok 31 - col_default_is( schema, table, column, default, description )
ok 32 - col_default_is( schema, table, column, default, description ) should work
ok 33 - col_default_is( schema, table, column, default, description ) fail
ok 34 - ok 33 - Should get proper diagnostics for a default failure
ok 35 - col_default_is( table, column, default, description )
ok 36 - col_default_is( table, column, default, description ) should work
ok 37 - col_default_is( table, column, default )
ok 38 - col_default_is( table, column, default ) should work
1..57
ok 1 - col_not_null( sch, tab, col, desc ) should pass
ok 2 - col_not_null( sch, tab, col, desc ) should have the proper description
ok 3 - col_not_null( sch, tab, col, desc ) should have the proper diagnostics
ok 4 - col_not_null( tab, col, desc ) should pass
ok 5 - col_not_null( tab, col, desc ) should have the proper description
ok 6 - col_not_null( tab, col, desc ) should have the proper diagnostics
ok 7 - col_not_null( table, column ) should pass
ok 8 - col_not_null( table, column ) should have the proper description
ok 9 - col_not_null( table, column ) should have the proper diagnostics
ok 10 - col_not_null( table, column ) fail should fail
ok 11 - col_not_null( table, column ) fail should have the proper description
ok 12 - col_not_null( table, column ) fail should have the proper diagnostics
ok 13 - col_is_null( sch, tab, col, desc ) should pass
ok 14 - col_is_null( sch, tab, col, desc ) should have the proper description
ok 15 - col_is_null( sch, tab, col, desc ) should have the proper diagnostics
ok 16 - col_is_null( tab, col, desc ) should pass
ok 17 - col_is_null( tab, col, desc ) should have the proper description
ok 18 - col_is_null( tab, col, desc ) should have the proper diagnostics
ok 19 - col_is_null( tab, col ) should pass
ok 20 - col_is_null( tab, col ) should have the proper description
ok 21 - col_is_null( tab, col ) should have the proper diagnostics
ok 22 - col_is_null( tab, col ) fail should fail
ok 23 - col_is_null( tab, col ) fail should have the proper description
ok 24 - col_is_null( tab, col ) fail should have the proper diagnostics
ok 25 - col_type_is( sch, tab, col, type, desc ) should pass
ok 26 - col_type_is( sch, tab, col, type, desc ) should have the proper description
ok 27 - col_type_is( sch, tab, col, type, desc ) should have the proper diagnostics
ok 28 - col_type_is( tab, col, type, desc ) should pass
ok 29 - col_type_is( tab, col, type, desc ) should have the proper description
ok 30 - col_type_is( tab, col, type, desc ) should have the proper diagnostics
ok 31 - col_type_is( tab, col, type ) should pass
ok 32 - col_type_is( tab, col, type ) should have the proper description
ok 33 - col_type_is( tab, col, type ) should have the proper diagnostics
ok 34 - col_type_is( tab, col, type ) insensitive should pass
ok 35 - col_type_is( tab, col, type ) insensitive should have the proper description
ok 36 - col_type_is( tab, col, type ) insensitive should have the proper diagnostics
ok 37 - col_type_is( tab, col, type ) fail should fail
ok 38 - col_type_is( tab, col, type ) fail should have the proper description
ok 39 - col_type_is( tab, col, type ) fail should have the proper diagnostics
ok 40 - col_type_is with precision should pass
ok 41 - col_type_is with precision should have the proper description
ok 42 - col_type_is with precision should have the proper diagnostics
ok 43 - col_type_is precision fail should fail
ok 44 - col_type_is precision fail should have the proper description
ok 45 - col_type_is precision fail should have the proper diagnostics
ok 46 - col_default_is( sch, tab, col, def, desc ) should pass
ok 47 - col_default_is( sch, tab, col, def, desc ) should have the proper description
ok 48 - col_default_is( sch, tab, col, def, desc ) should have the proper diagnostics
ok 49 - col_default_is() fail should fail
ok 50 - col_default_is() fail should have the proper description
ok 51 - col_default_is() fail should have the proper diagnostics
ok 52 - col_default_is( tab, col, def, desc ) should pass
ok 53 - col_default_is( tab, col, def, desc ) should have the proper description
ok 54 - col_default_is( tab, col, def, desc ) should have the proper diagnostics
ok 55 - col_default_is( tab, col, def ) should pass
ok 56 - col_default_is( tab, col, def ) should have the proper description
ok 57 - col_default_is( tab, col, def ) should have the proper diagnostics
196 changes: 102 additions & 94 deletions sql/coltap.sql
Expand Up @@ -3,7 +3,7 @@

-- $Id$

SELECT plan(38);
SELECT plan(57);

-- This will be rolled back. :-)
CREATE TABLE public.sometab(
Expand All @@ -15,163 +15,171 @@ CREATE TABLE public.sometab(

/****************************************************************************/
-- Test col_not_null().
\echo ok 1 - testing col_not_null( schema, table, column, desc )
SELECT is(
SELECT * FROM check_test(
col_not_null( 'pg_catalog', 'pg_type', 'typname', 'typname not null' ),
'ok 1 - typname not null',
'col_not_null( schema, table, column, desc ) should work'
true,
'col_not_null( sch, tab, col, desc )',
'typname not null',
''
);
\echo ok 3 - testing col_not_null( table, column, desc )
SELECT is(

SELECT * FROM check_test(
col_not_null( 'sometab', 'id', 'blah blah blah' ),
'ok 3 - blah blah blah',
'col_not_null( table, column, desc ) should work'
true,
'col_not_null( tab, col, desc )',
'blah blah blah',
''
);

\echo ok 5 - testing col_not_null( schema, table, column, desc )
SELECT is(
SELECT * FROM check_test(
col_not_null( 'sometab', 'id' ),
'ok 5 - Column sometab(id) should be NOT NULL',
'col_not_null( table, column ) should work'
true,
'col_not_null( table, column )',
'Column sometab(id) should be NOT NULL',
''
);

-- Make sure failure is correct.
\echo ok 7 - testing col_not_null( schema, table, column, desc )
SELECT is(
SELECT * FROM check_test(
col_not_null( 'sometab', 'name' ),
'not ok 7 - Column sometab(name) should be NOT NULL
# Failed test 7: "Column sometab(name) should be NOT NULL"',
'col_not_null( table, column ) should properly fail'
false,
'col_not_null( table, column ) fail',
'Column sometab(name) should be NOT NULL',
''
);
UPDATE __tresults__ SET ok = true, aok = true WHERE numb IN( 7 );

/****************************************************************************/
-- Test col_is_null().
\echo ok 9 - testing col_is_null( schema, table, column, desc )
SELECT is(
SELECT * FROM check_test(
col_is_null( 'public', 'sometab', 'name', 'name is null' ),
'ok 9 - name is null',
'col_is_null( schema, table, column, desc ) should work'
true,
'col_is_null( sch, tab, col, desc )',
'name is null',
''
);
\echo ok 11 - testing col_is_null( table, column, desc )
SELECT is(

SELECT * FROM check_test(
col_is_null( 'sometab', 'name', 'my desc' ),
'ok 11 - my desc',
'col_is_null( table, column, desc ) should work'
true,
'col_is_null( tab, col, desc )',
'my desc',
''
);

\echo ok 13 - testing col_is_null( schema, table, column, desc )
SELECT is(
SELECT * FROM check_test(
col_is_null( 'sometab', 'name' ),
'ok 13 - Column sometab(name) should allow NULL',
'col_is_null( table, column ) should work'
true,
'col_is_null( tab, col )',
'Column sometab(name) should allow NULL',
''
);
-- Make sure failure is correct.
\echo ok 15 - testing col_is_null( schema, table, column, desc )
SELECT is(
SELECT * FROM check_test(
col_is_null( 'sometab', 'id' ),
'not ok 15 - Column sometab(id) should allow NULL
# Failed test 15: "Column sometab(id) should allow NULL"',
'col_is_null( table, column ) should properly fail'
false,
'col_is_null( tab, col ) fail',
'Column sometab(id) should allow NULL',
''
);
UPDATE __tresults__ SET ok = true, aok = true WHERE numb IN( 15 );

/****************************************************************************/
-- Test col_type_is().
\echo ok 17 - testing col_type_is( schema, table, column, type, desc )
SELECT is(
SELECT * FROM check_test(
col_type_is( 'public', 'sometab', 'name', 'text', 'name is text' ),
'ok 17 - name is text',
'col_type_is( schema, table, column, type, desc ) should work'
true,
'col_type_is( sch, tab, col, type, desc )',
'name is text',
''
);

\echo ok 19 - testing col_type_is( table, column, type, desc )
SELECT is(
SELECT * FROM check_test(
col_type_is( 'sometab', 'name', 'text', 'yadda yadda yadda' ),
'ok 19 - yadda yadda yadda',
'col_type_is( table, column, type, desc ) should work'
true,
'col_type_is( tab, col, type, desc )',
'yadda yadda yadda',
''
);

\echo ok 21 - testing col_type_is( table, column, type )
SELECT is(
SELECT * FROM check_test(
col_type_is( 'sometab', 'name', 'text' ),
'ok 21 - Column sometab(name) should be type text',
'col_type_is( table, column, type ) should work'
true,
'col_type_is( tab, col, type )',
'Column sometab(name) should be type text',
''
);

\echo ok 23 - testing col_type_is( table, column, type ) case-insensitively
SELECT is(
SELECT * FROM check_test(
col_type_is( 'sometab', 'name', 'TEXT' ),
'ok 23 - Column sometab(name) should be type TEXT',
'col_type_is( table, column, type ) should work case-insensitively'
true,
'col_type_is( tab, col, type ) insensitive',
'Column sometab(name) should be type TEXT',
''
);

-- Make sure failure is correct.
\echo ok 25 - testing col_type_is( table, column, type ) failure
SELECT is(
SELECT * FROM check_test(
col_type_is( 'sometab', 'name', 'int4' ),
'not ok 25 - Column sometab(name) should be type int4
# Failed test 25: "Column sometab(name) should be type int4"
# have: text
# want: int4',
'col_type_is( table, column, type ) should fail with proper diagnostics'
false,
'col_type_is( tab, col, type ) fail',
'Column sometab(name) should be type int4',
' have: text
want: int4'
);
UPDATE __tresults__ SET ok = true, aok = true WHERE numb IN( 25 );

/****************************************************************************/
-- Try col_type_is() with precision.
\echo ok 27 - testing col_type_is( schema, table, column, type(precision,scale), description )
SELECT is(
SELECT * FROM check_test(
col_type_is( 'public', 'sometab', 'numb', 'numeric(10,2)', 'lol' ),
'ok 27 - lol',
'col_type_is( schema, table, column, type, precision(scale,description) should work'
true,
'col_type_is with precision',
'lol',
''
);

-- Check its diagnostics.
\echo ok 29 - col_type_is( table, column, type, precision, desc ) fail
SELECT is(
SELECT * FROM check_test(
col_type_is( 'sometab', 'myint', 'numeric(7)', 'should be numeric(7)' ),
'not ok 29 - should be numeric(7)
# Failed test 29: "should be numeric(7)"
# have: numeric(8,0)
# want: numeric(7)',
'col_type_is with precision should have nice diagnostics'
false,
'col_type_is precision fail',
'should be numeric(7)',
' have: numeric(8,0)
want: numeric(7)'
);

UPDATE __tresults__ SET ok = true, aok = true WHERE numb IN( 29 );

/****************************************************************************/
-- Test col_default_is().

\echo ok 31 - col_default_is( schema, table, column, default, description )
SELECT is(
SELECT * FROM check_test(
col_default_is( 'public', 'sometab', 'name', ''::text, 'name should default to empty string' ),
'ok 31 - name should default to empty string',
'col_default_is( schema, table, column, default, description ) should work'
true,
'col_default_is( sch, tab, col, def, desc )',
'name should default to empty string',
''
);

\echo ok 33 - col_default_is( schema, table, column, default, description ) fail
SELECT is(
SELECT * FROM check_test(
col_default_is( 'public', 'sometab', 'name', 'foo'::text, 'name should default to ''foo''' ),
'not ok 33 - name should default to ''foo''
# Failed test 33: "name should default to ''foo''"
# have:
# want: foo',
'ok 33 - Should get proper diagnostics for a default failure'
false,
'col_default_is() fail',
'name should default to ''foo''',
' have:
want: foo'
);
UPDATE __tresults__ SET ok = true, aok = true WHERE numb IN( 33 );

\echo ok 35 - col_default_is( table, column, default, description )
SELECT is(
SELECT * FROM check_test(
col_default_is( 'sometab', 'name', ''::text, 'name should default to empty string' ),
'ok 35 - name should default to empty string',
'col_default_is( table, column, default, description ) should work'
true,
'col_default_is( tab, col, def, desc )',
'name should default to empty string',
''
);

\echo ok 37 - col_default_is( table, column, default )
SELECT is(
SELECT * FROM check_test(
col_default_is( 'sometab', 'name', '' ),
'ok 37 - Column sometab(name) should default to ''''',
'col_default_is( table, column, default ) should work'
true,
'col_default_is( tab, col, def )',
'Column sometab(name) should default to ''''',
''
);

/****************************************************************************/
Expand Down

0 comments on commit ca6fa97

Please sign in to comment.