File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -305,17 +305,19 @@ What a sweet unit!
305
305
306
306
If you're used to xUnit testing frameworks, you can collect all of your tests
307
307
into database functions and run them all at once with `runtests()`. This is
308
- similar to how [PGUnit](http://en.dklab.ru/lib/dklab_pgunit/)s . The
308
+ similar to how [PGUnit](http://en.dklab.ru/lib/dklab_pgunit/) works . The
309
309
`runtests()` function does all the work of finding and running your test
310
310
functions in individual transactions. It even supports setup and teardown
311
311
functions. To use it, write your unit test functions so that they return a set
312
312
of text results, and then use the pgTAP assertion functions to return TAP
313
- values, like so :
313
+ values. Here's an example, testing a hypothetical `users` table :
314
314
315
315
CREATE OR REPLACE FUNCTION setup_insert(
316
316
) RETURNS SETOF TEXT AS $$
317
+ BEGIN
317
318
RETURN NEXT is( MAX(nick), NULL, 'Should have no users') FROM users;
318
319
INSERT INTO users (nick) VALUES ('theory');
320
+ END;
319
321
$$ LANGUAGE plpgsql;
320
322
321
323
CREATE OR REPLACE FUNCTION test_user(
You can’t perform that action at this time.
0 commit comments