这个 pgTAP 测试
BEGIN;
CREATE OR REPLACE FUNCTION test.testXUnitStyle() RETURNS SETOF TEXT AS $$
SELECT ok(4 * 5 = 20, 'math should work in postgres');
$$ LANGUAGE plpgsql;
SELECT * FROM runtests('test'::name);
给了我这个语法错误:
prove --ext .sql t/pgtap-xunit.sql --source pgTAP --pgtap-option dbname=test
psql:t/pgtap-xunit.sql:5: ERROR: syntax error at or near "SELECT"
LINE 2: SELECT ok(4 * 5 = 20, 'math should work in postgres');
^
t/pgtap-xunit.sql .. Dubious, test returned 3 (wstat 768, 0x300)
No subtests run
Test Summary Report
-------------------
t/pgtap-xunit.sql (Wstat: 768 Tests: 0 Failed: 0)
Non-zero exit status: 3
Parse errors: No plan found in TAP output
Files=1, Tests=0, 0 wallclock secs ( 0.03 usr + 0.00 sys = 0.03 CPU)
Result: FAIL
但如果我将它更改LANGUAGE plpgsql
为LANGUAGE sql
它就可以了。
我需要做什么才能以 plpgsql 运行测试?