Changeset 20 for trunk/epic/epic.sql
- Timestamp:
- 08/28/08 16:50:51 (4 years ago)
- Files:
-
- 1 modified
-
trunk/epic/epic.sql (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/epic/epic.sql
r19 r20 346 346 output_record test.results%ROWTYPE; 347 347 BEGIN 348 FOR testname IN SELECT name FROM test.testnames WHERE module = modulename 348 FOR testname IN SELECT name FROM test.testnames WHERE module = modulename ORDER BY name ASC 349 349 LOOP 350 350 SELECT INTO output_record * FROM test.run_test(testname); … … 364 364 FOR modulename in SELECT DISTINCT module FROM test.testnames ORDER BY module ASC 365 365 LOOP 366 FOR testname IN SELECT name FROM test.testnames WHERE module = modulename 366 FOR testname IN SELECT name FROM test.testnames WHERE module = modulename ORDER BY name ASC 367 367 LOOP 368 368 SELECT INTO output_record * FROM test.run_test(testname); … … 763 763 764 764 765 CREATE OR REPLACE FUNCTION test.assert_empty( tablenames text[]) RETURNS VOID AS $$766 -- Raises an exception if the given tables have any rows.765 CREATE OR REPLACE FUNCTION test.assert_empty(calls text[]) RETURNS VOID AS $$ 766 -- Raises an exception if the given calls have any rows. 767 767 DECLARE 768 768 result bool; … … 770 770 failed_len int; 771 771 BEGIN 772 IF array_lower( tablenames, 1) IS NOT NULL THEN773 FOR i in array_lower( tablenames, 1)..array_upper(tablenames, 1)772 IF array_lower(calls, 1) IS NOT NULL THEN 773 FOR i in array_lower(calls, 1)..array_upper(calls, 1) 774 774 LOOP 775 EXECUTE 'SELECT (EXISTS (SELECT 1 FROM ' || tablenames[i] || '));' INTO result;775 EXECUTE 'SELECT EXISTS (' || test.statement(calls[i]) || ');' INTO result; 776 776 IF result THEN 777 failed := failed || ('"' || btrim( tablenames[i]) || '"');777 failed := failed || ('"' || btrim(calls[i]) || '"'); 778 778 END IF; 779 779 END LOOP; … … 783 783 failed_len := (array_upper(failed, 1) - array_lower(failed, 1)) + 1; 784 784 IF failed_len = 1 THEN 785 PERFORM test.fail('The table' || array_to_string(failed, ', ') || ' is not empty.');785 PERFORM test.fail('The call ' || array_to_string(failed, ', ') || ' is not empty.'); 786 786 ELSEIF failed_len > 1 THEN 787 PERFORM test.fail('The tables ' || array_to_string(failed, ', ') || ' are not empty.');787 PERFORM test.fail('The calls ' || array_to_string(failed, ', ') || ' are not empty.'); 788 788 END IF; 789 789 END IF; … … 791 791 $$ LANGUAGE plpgsql; 792 792 793 CREATE OR REPLACE FUNCTION test.assert_empty( tablenametext) RETURNS VOID AS $$794 -- Raises an exception if the given table has any rows.793 CREATE OR REPLACE FUNCTION test.assert_empty(call text) RETURNS VOID AS $$ 794 -- Raises an exception if the given call returns any rows. 795 795 DECLARE 796 796 result bool; 797 797 BEGIN 798 IF tablename LIKE '%,%' THEN 799 PERFORM test.assert_empty(string_to_array(tablename, ',')); 800 RETURN; 801 END IF; 802 803 EXECUTE 'SELECT (EXISTS (SELECT 1 FROM ' || tablename || '));' INTO result; 798 EXECUTE 'SELECT EXISTS (' || test.statement(call) || ');' INTO result; 804 799 IF result THEN 805 PERFORM test.fail('The table "' || tablename|| '" is not empty.');806 END IF; 807 END; 808 $$ LANGUAGE plpgsql; 809 810 811 CREATE OR REPLACE FUNCTION test.assert_not_empty( tablenames text[]) RETURNS VOID AS $$812 -- Raises an exception if the given tables have no rows.800 PERFORM test.fail('The call "' || call || '" is not empty.'); 801 END IF; 802 END; 803 $$ LANGUAGE plpgsql; 804 805 806 CREATE OR REPLACE FUNCTION test.assert_not_empty(calls text[]) RETURNS VOID AS $$ 807 -- Raises an exception if the given calls have no rows. 813 808 DECLARE 814 809 result bool; … … 816 811 failed_len int; 817 812 BEGIN 818 IF array_lower( tablenames, 1) IS NOT NULL THEN819 FOR i in array_lower( tablenames, 1)..array_upper(tablenames, 1)813 IF array_lower(calls, 1) IS NOT NULL THEN 814 FOR i in array_lower(calls, 1)..array_upper(calls, 1) 820 815 LOOP 821 EXECUTE 'SELECT (EXISTS (SELECT 1 FROM ' || tablenames[i] || '));' INTO result;816 EXECUTE 'SELECT EXISTS (' || test.statement(calls[i]) || ');' INTO result; 822 817 IF NOT result THEN 823 failed := failed || ('"' || btrim( tablenames[i]) || '"');818 failed := failed || ('"' || btrim(calls[i]) || '"'); 824 819 END IF; 825 820 END LOOP; … … 832 827 failed_len := (array_upper(failed, 1) - array_lower(failed, 1)) + 1; 833 828 IF failed_len = 1 THEN 834 PERFORM test.fail('The table' || array_to_string(failed, ', ') || ' is empty.');829 PERFORM test.fail('The call ' || array_to_string(failed, ', ') || ' is empty.'); 835 830 ELSEIF failed_len > 1 THEN 836 PERFORM test.fail('The tables ' || array_to_string(failed, ', ') || ' are empty.');831 PERFORM test.fail('The calls ' || array_to_string(failed, ', ') || ' are empty.'); 837 832 END IF; 838 833 END IF; … … 840 835 $$ LANGUAGE plpgsql; 841 836 842 CREATE OR REPLACE FUNCTION test.assert_not_empty( tablenametext) RETURNS VOID AS $$837 CREATE OR REPLACE FUNCTION test.assert_not_empty(call text) RETURNS VOID AS $$ 843 838 -- Raises an exception if the given table has no rows. 844 839 DECLARE 845 840 result bool; 846 841 BEGIN 847 IF tablename LIKE '%,%' THEN 848 PERFORM test.assert_not_empty(string_to_array(tablename, ',')); 849 RETURN; 850 END IF; 851 852 EXECUTE 'SELECT (EXISTS (SELECT 1 FROM ' || tablename || '));' INTO result; 842 EXECUTE 'SELECT EXISTS (' || test.statement(call) || ');' INTO result; 853 843 IF NOT result THEN 854 PERFORM test.fail('The table "' || tablename|| '" is empty.');855 END IF; 856 END; 857 $$ LANGUAGE plpgsql; 858 844 PERFORM test.fail('The call "' || call || '" is empty.'); 845 END IF; 846 END; 847 $$ LANGUAGE plpgsql; 848
