Skip to content

Commit

Permalink
Add missing BEING/END to PL/pgSQL function.
Browse files Browse the repository at this point in the history
And add a comment about the hypothetical `users` table. Resolves #163.
  • Loading branch information
theory committed Apr 2, 2018
1 parent ba2236c commit 112fdee
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions doc/pgtap.mmd
Expand Up @@ -305,17 +305,19 @@ What a sweet unit!

If you're used to xUnit testing frameworks, you can collect all of your tests
into database functions and run them all at once with `runtests()`. This is
similar to how [PGUnit](http://en.dklab.ru/lib/dklab_pgunit/)s. The
similar to how [PGUnit](http://en.dklab.ru/lib/dklab_pgunit/) works. The
`runtests()` function does all the work of finding and running your test
functions in individual transactions. It even supports setup and teardown
functions. To use it, write your unit test functions so that they return a set
of text results, and then use the pgTAP assertion functions to return TAP
values, like so:
values. Here's an example, testing a hypothetical `users` table:

CREATE OR REPLACE FUNCTION setup_insert(
) RETURNS SETOF TEXT AS $$
BEGIN
RETURN NEXT is( MAX(nick), NULL, 'Should have no users') FROM users;
INSERT INTO users (nick) VALUES ('theory');
END;
$$ LANGUAGE plpgsql;

CREATE OR REPLACE FUNCTION test_user(
Expand Down

0 comments on commit 112fdee

Please sign in to comment.