Show
Ignore:
Timestamp:
09/03/08 08:55:33 (4 years ago)
Author:
fumanchu
Message:

Added __create__, __record__, __iter__, __attributes__, and __len__ to global records. Moved the 'attributes' function into the test schema.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/epic/test/test_globals.sql

    r16 r22  
    1212  PERFORM test.assert_equal(rec.nspname, 'test'); 
    1313   
    14   -- The returned record MUST possess a .tablename attribute. 
    15   PERFORM test.assert(rec.tablename LIKE E'\_global\_%', rec.tablename || ' not like _global'); 
     14  -- The returned record MUST possess a .__name__ attribute. 
     15  PERFORM test.assert(rec.__name__ LIKE E'\_global\_%', rec.__name__ || ' not like _global'); 
    1616   
    17   -- The tablename MUST reference a temporary table with the same fields. 
    18   EXECUTE 'SELECT * FROM ' || rec.tablename INTO trec; 
     17  -- The .__name__ MUST reference a temporary table with the same fields. 
     18  EXECUTE 'SELECT * FROM ' || rec.__name__ INTO trec; 
    1919  PERFORM test.assert_equal(trec.nspname, 'test'); 
    2020  PERFORM test.assert_equal(trec.nspowner, rec.nspowner); 
    2121  PERFORM test.assert_equal(trec.nspacl, rec.nspacl); 
    2222   
    23   RAISE EXCEPTION '%', rec.tablename; 
     23  -- The returned record MUST possess a .__create__ attribute. 
     24  PERFORM test.assert_equal(rec.__create__, 'SELECT * FROM pg_namespace WHERE nspname = ''test'''); 
     25   
     26  -- The returned record MUST possess a .__record__ attribute. 
     27  PERFORM test.assert_equal(rec.__record__, 
     28    'SELECT * FROM _global_record(''' || rec.__name__ || ''', ''' || rec.__create__ || ''')'); 
     29   
     30  -- The returned record MUST possess an .__iter__ attribute. 
     31  PERFORM test.assert_equal(rec.__iter__, 'SELECT * FROM ' || rec.__name__); 
     32  PERFORM test.assert_not_empty(rec.__iter__); 
     33   
     34  -- The returned record MUST possess an .__attributes__ attribute. 
     35  PERFORM test.assert_equal(rec.__attributes__, 'SELECT attname FROM test.attributes(''' || rec.__name__ || ''')'); 
     36  PERFORM test.assert_column(rec.__attributes__, ARRAY['nspname', 'nspowner', 'nspacl']); 
     37   
     38  -- The returned record MUST possess a .__len__ attribute. 
     39  PERFORM test.assert_equal(rec.__len__, 1); 
     40   
     41  -- Raise an exception to test deletion of the TEMP table ON COMMIT 
     42  RAISE EXCEPTION '%', rec.__name__; 
    2443END; 
    2544$$ LANGUAGE plpgsql;