1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184
|
\unset ECHO
\i test/setup.sql
SELECT plan(36);
--SELECT * FROM no_plan();
/****************************************************************************/
-- Test todo tests.
\echo ok 1 - todo fail
\echo ok 2 - todo pass
SELECT * FROM todo('just because', 2 );
SELECT is(
fail('This is a todo test' ) || '
'
|| pass('This is a todo test that unexpectedly passes' ),
'not ok 1 - This is a todo test # TODO just because
# Failed (TODO) test 1: "This is a todo test"
ok 2 - This is a todo test that unexpectedly passes # TODO just because',
'TODO tests should display properly'
);
-- Try just a reason.
\echo ok 4 - todo fail
SELECT * FROM todo( 'for whatever reason' );
SELECT is(
fail('Another todo test'),
'not ok 4 - Another todo test # TODO for whatever reason
# Failed (TODO) test 4: "Another todo test"',
'Single default todo test should display properly'
);
-- Try just a number.
\echo ok 6 - todo fail
\echo ok 7 - todo pass
SELECT * FROM todo( 2 );
SELECT is(
fail('This is a todo test' ) || '
'
|| pass('This is a todo test that unexpectedly passes' ),
'not ok 6 - This is a todo test # TODO
# Failed (TODO) test 6: "This is a todo test"
ok 7 - This is a todo test that unexpectedly passes # TODO ',
'TODO tests should display properly'
);
/****************************************************************************/
-- Test skipping tests.
SELECT * FROM check_test(
skip('Just because'),
true,
'simple skip',
'',
'SKIP Just because'
);
SELECT * FROM check_test(
skip('Just because', 1),
true,
'skip with num',
'',
'SKIP Just because'
);
\echo ok 15 - Skip multiple
\echo ok 16 - Skip multiple
\echo ok 17 - Skip multiple
SELECT is(
skip( 'Whatever', 3 ),
'ok 15 # SKIP Whatever
ok 16 # SKIP Whatever
ok 17 # SKIP Whatever',
'We should get the proper output for multiple skips'
);
-- Test inversion.
SELECT * FROM check_test(
skip(1, 'Just because'),
true,
'inverted skip',
'',
'SKIP Just because'
);
-- Test num only.
SELECT * FROM check_test(
skip(1),
true,
'num only',
'',
'SKIP'
);
/****************************************************************************/
-- Try nesting todo tests.
\echo ok 25 - todo fail
\echo ok 26 - todo fail
\echo ok 27 - todo fail
SELECT * FROM todo('just because', 2 );
SELECT is(
ARRAY(
SELECT fail('This is a todo test 1') AS stuff
UNION
SELECT todo::text FROM todo('inside')
UNION
SELECT fail('This is a todo test 2')
UNION
SELECT fail('This is a todo test 3')
ORDER BY stuff
),
ARRAY[
'not ok 25 - This is a todo test 1 # TODO just because
# Failed (TODO) test 25: "This is a todo test 1"',
'not ok 26 - This is a todo test 2 # TODO inside
# Failed (TODO) test 26: "This is a todo test 2"',
'not ok 27 - This is a todo test 3 # TODO just because
# Failed (TODO) test 27: "This is a todo test 3"'
],
'Nested todos should work properly'
);
/****************************************************************************/
-- Test todo_start() and todo_end().
\echo ok 29 - todo fail
\echo ok 30 - todo fail
\echo ok 31 - todo fail
SELECT * FROM todo_start('some todos');
SELECT is(
ARRAY(
SELECT fail('This is a todo test 1') AS stuff
UNION
SELECT in_todo()::text
UNION
SELECT todo::text FROM todo('inside')
UNION
SELECT fail('This is a todo test 2')
UNION
SELECT fail('This is a todo test 3')
UNION
SELECT todo_end::text FROM todo_end()
UNION
SELECT in_todo()::text
ORDER BY stuff
),
ARRAY[
'false',
'not ok 29 - This is a todo test 1 # TODO some todos
# Failed (TODO) test 29: "This is a todo test 1"',
'not ok 30 - This is a todo test 2 # TODO inside
# Failed (TODO) test 30: "This is a todo test 2"',
'not ok 31 - This is a todo test 3 # TODO some todos
# Failed (TODO) test 31: "This is a todo test 3"',
'true'
],
'todo_start() and todo_end() should work properly with in_todo()'
);
/****************************************************************************/
-- Make sure we can reverse the arguments.
\echo ok 33 - todo fail
\echo ok 34 - todo pass
SELECT * FROM todo(2, 'just because' );
SELECT is(
fail('This is a todo test' ) || '
'
|| fail('Another todo test'),
'not ok 33 - This is a todo test # TODO just because
# Failed (TODO) test 33: "This is a todo test"
not ok 34 - Another todo test # TODO just because
# Failed (TODO) test 34: "Another todo test"',
'Should be able to revers the arguments to todo()'
);
-- Test the exception.
SELECT throws_ok(
'SELECT todo_end()',
'P0001',
'todo_end() called without todo_start()',
'Should get an exception when todo_end() is called without todo_start()'
);
/****************************************************************************/
-- Finish the tests and clean up.
SELECT * FROM finish();
ROLLBACK;
|