Changeset 9 for trunk/epic
- Timestamp:
- 08/17/08 01:47:59 (4 years ago)
- Location:
- trunk/epic
- Files:
-
- 2 modified
-
epic.sql (modified) (5 diffs)
-
test/test_asserts.sql (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/epic/epic.sql
r8 r9 190 190 BEGIN 191 191 CREATE TABLE test.results (name text PRIMARY KEY, module text, 192 ok boolean, errcode text, errmsg text); 193 EXCEPTION WHEN duplicate_table THEN 194 NULL; 195 END; 196 197 BEGIN 198 CREATE TYPE test.suite_results AS (name text, module text, result text, 199 errcode text, errmsg text); 192 result text, errcode text, errmsg text); 200 193 EXCEPTION WHEN duplicate_table THEN 201 194 NULL; … … 219 212 220 213 221 CREATE OR REPLACE FUNCTION test.run_test(testname text) RETURNS test. suite_results AS $$214 CREATE OR REPLACE FUNCTION test.run_test(testname text) RETURNS test.results AS $$ 222 215 -- Runs the named test, stores in test.results, and returns success. 223 216 DECLARE 224 217 modulename text; 225 output_record test. suite_results%ROWTYPE;218 output_record test.results%ROWTYPE; 226 219 BEGIN 227 220 SELECT module INTO modulename FROM test.testnames WHERE name = testname; … … 231 224 EXECUTE 'SELECT * FROM test.' || testname || '();'; 232 225 EXCEPTION WHEN OTHERS THEN 233 IF SQLERRM = '[OK]' THEN 234 INSERT INTO test.results (name, module, ok) 235 VALUES (testname, modulename, TRUE) 236 RETURNING name, module, CASE WHEN ok=true THEN '[OK]' ELSE '[FAIL]' END, errcode, errmsg 237 INTO output_record; 226 IF SQLERRM LIKE '[%]' THEN 227 INSERT INTO test.results (name, module, result) 228 VALUES (testname, modulename, SQLERRM) 229 RETURNING * INTO output_record; 238 230 RETURN output_record; 239 231 ELSE 240 INSERT INTO test.results (name, module, ok, errcode, errmsg) 241 VALUES (testname, modulename, FALSE, SQLSTATE, SQLERRM) 242 RETURNING name, module, CASE WHEN ok=true THEN '[OK]' ELSE '[FAIL]' END, errcode, errmsg 243 INTO output_record; 232 INSERT INTO test.results (name, module, result, errcode, errmsg) 233 VALUES (testname, modulename, '[FAIL]', SQLSTATE, SQLERRM) 234 RETURNING * INTO output_record; 244 235 RETURN output_record; 245 236 END IF; … … 251 242 252 243 253 CREATE OR REPLACE FUNCTION test.run_module(modulename text) RETURNS SETOF test. suite_results AS $$244 CREATE OR REPLACE FUNCTION test.run_module(modulename text) RETURNS SETOF test.results AS $$ 254 245 -- Runs all tests in the given module, stores in test.results, and returns results. 255 246 DECLARE 256 247 testname pg_proc.proname%TYPE; 257 output_record test. suite_results%ROWTYPE;248 output_record test.results%ROWTYPE; 258 249 BEGIN 259 250 FOR testname IN SELECT name FROM test.testnames WHERE module = modulename … … 266 257 267 258 268 CREATE OR REPLACE FUNCTION test.run_all() RETURNS SETOF test. suite_results AS $$259 CREATE OR REPLACE FUNCTION test.run_all() RETURNS SETOF test.results AS $$ 269 260 -- Runs all known test functions, stores in test.results, and returns results. 270 261 DECLARE 271 262 testname pg_proc.proname%TYPE; 272 263 modulename text; 273 output_record test. suite_results%ROWTYPE;264 output_record test.results%ROWTYPE; 274 265 BEGIN 275 266 FOR modulename in SELECT DISTINCT module FROM test.testnames ORDER BY module ASC -
trunk/epic/test/test_asserts.sql
r5 r9 24 24 IF objname IS NULL THEN 25 25 RAISE EXCEPTION 'assert_test_schema did not create a test.results table.'; 26 END IF;27 28 -- assert_test_schema MUST create a 'test.suite_results' type29 SELECT typname INTO objname FROM pg_type30 WHERE typnamespace = nsoid AND typname = 'suite_results';31 IF objname IS NULL THEN32 RAISE EXCEPTION 'assert_test_schema did not create a test.suite_results type.';33 26 END IF; 34 27
