root/trunk/epic/test/test_core.sql

Revision 30, 1.2 kB (checked in by fumanchu, 3 years ago)

Fix for #4 (Allow VALUES Query in assert_rows()).

  • Property svn:executable set to *
Line 
1-- Tests for core functions which Epic provides.
2-- To run, execute epic.sql, then this script, then test.run_module('test_core').
3
4CREATE OR REPLACE FUNCTION test.test_statement() RETURNS VOID AS $$
5-- module: test_core
6DECLARE
7  t    text;
8BEGIN
9  -- Test a passthrough
10  SELECT INTO t * FROM test.statement('SELECT 1');
11  PERFORM test.assert_equal(t, 'SELECT 1');
12 
13  -- Test missing SELECT
14  SELECT INTO t * FROM test.statement('generate_series()');
15  PERFORM test.assert_equal(t, 'SELECT * FROM generate_series()');
16 
17  -- Test leading whitespace
18  SELECT INTO t * FROM test.statement('    SELECT 1');
19  PERFORM test.assert_equal(t, '    SELECT 1');
20 
21  -- Test leading whitespace, no SELECT
22  SELECT INTO t * FROM test.statement('   generate_series()   ');
23  PERFORM test.assert_equal(t, 'SELECT * FROM    generate_series()   ');
24 
25  -- Test EXECUTE
26  SELECT INTO t * FROM test.statement('EXECUTE myfoo');
27  PERFORM test.assert_equal(t, 'EXECUTE myfoo');
28 
29  -- Test VALUES
30  SELECT INTO t * FROM test.statement('VALUES (99, ''foo'')');
31  PERFORM test.assert_equal(t, 'VALUES (99, ''foo'')');
32  SELECT INTO t * FROM test.statement('VALUES(99, ''foo'')');
33  PERFORM test.assert_equal(t, 'VALUES(99, ''foo'')');
34 
35  PERFORM test.pass();
36END;
37$$ LANGUAGE plpgsql;
Note: See TracBrowser for help on using the browser.