Changeset 4296
- Timestamp:
- Jun 17, 2005, 11:32:44 AM (21 years ago)
- Location:
- trunk/psLib/test/dataIO
- Files:
-
- 2 edited
-
tst_psDB.c (modified) (4 diffs)
-
verified/tst_psDB.stderr (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/dataIO/tst_psDB.c
r4295 r4296 9 9 * @author Aaron Culliney, MHPCC 10 10 * 11 * @version $Revision: 1.2 0$ $Name: not supported by cvs2svn $12 * @date $Date: 2005-06-17 02:56:26$11 * @version $Revision: 1.21 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2005-06-17 21:32:44 $ 13 13 * 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 61 61 const char *key5, const char *comm5, psS32 val5); 62 62 static psMetadata *_get_row( void ); 63 static psMetadata *_get_invalid_row( void ); 63 64 static psMetadata *_get_where( void ); 64 65 static psMetadata *_get_update_values(const char *val0, psS32 val1, psF32 val2, psF64 val3, psBool val4); … … 232 233 } 233 234 235 psMetadata *_get_invalid_row( void ) 236 { 237 return _get_RowMetadata( 238 "key_string", "comment-string", STR_1, 239 "key_s32", "comment-s32", S32_1, 240 "key_999", "comment-f32", F32_1, 241 "key_f64", "comment-f64", F64_1, 242 "key_bool", "comment-bool", B_1, 243 NULL, NULL, 0.0); 244 } 245 234 246 psMetadata *_get_where( void ) 235 247 { … … 979 991 } 980 992 981 // Testpoint # XXX, TPDBInsertOneRow shall write a row of data into a test table ...993 // Testpoint #848, TPDBInsertOneRow shall write a row of data into a test table ... 982 994 psS32 TPDBInsertOneRow( void ) 983 995 { 984 psS32 failed = 0;985 996 psDB *dbh = NULL; 986 997 const char* table = "table6"; 998 psMetadata *invalidRow = NULL; 999 1000 // Create table definition metadata 987 1001 psMetadata *row=NULL, *md = _get_CreateTableMetadata(); 988 1002 1003 // Initialize database connection 989 1004 dbh = _init_psDB(); 990 1005 if (dbh == NULL) { 1006 psError(PS_ERR_UNKNOWN,true,"Did not expect return NULL for database initialization"); 991 1007 return 1; 992 1008 } 993 1009 994 psLogMsg( __func__, PS_LOG_INFO, "psDBInsertOneRow shall insert a row into a test table.\n" ); 995 996 failed = ! psDBCreateTable(dbh, table, md); 997 if (!failed) { 998 row = _get_const_row1(); 999 failed = ! psDBInsertOneRow(dbh, table, row); 1000 psFree(row); 1001 psDBDropTable(dbh, table); 1002 } 1003 1010 // Create database table 1011 if(!psDBCreateTable(dbh, table, md)) { 1012 psError(PS_ERR_UNKNOWN,true,"Did not expect return false for create database"); 1013 psDBCleanup(dbh); 1014 return 2; 1015 } 1016 1017 // Insert a single row with valid arguments 1018 row = _get_const_row1(); 1019 if(!psDBInsertOneRow(dbh, table, row)) { 1020 psError(PS_ERR_UNKNOWN,true,"Did not expect return false for inserting row w/ valid arguments"); 1021 psDBDropTable(dbh,table); 1022 psDBCleanup(dbh); 1023 return 3; 1024 } 1025 1026 // Insert a single row with NULL database 1027 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message for NULL database"); 1028 if(psDBInsertOneRow(NULL,table,row)) { 1029 psError(PS_ERR_UNKNOWN,true,"Did not expect return value true for NULL database"); 1030 psDBDropTable(dbh,table); 1031 psDBCleanup(dbh); 1032 return 4; 1033 } 1034 1035 // Insert a single row which has column which does not match table 1036 invalidRow = _get_invalid_row(); 1037 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message for invalid column item"); 1038 if(psDBInsertOneRow(dbh,table,invalidRow)) { 1039 psError(PS_ERR_UNKNOWN,true,"Did not expect return value true for invalid column item"); 1040 psDBDropTable(dbh,table); 1041 psDBCleanup(dbh); 1042 return 6; 1043 } 1044 1045 // Insert a single row with invalid table 1046 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message for invalid table"); 1047 if(psDBInsertOneRow(dbh,"table999",row)) { 1048 psError(PS_ERR_UNKNOWN,true,"Did not expect return value true for invalid table"); 1049 psDBDropTable(dbh,table); 1050 psDBCleanup(dbh); 1051 return 5; 1052 } 1053 1054 // Insert a single row with NULL row 1055 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message for NULL row"); 1056 if(psDBInsertOneRow(dbh,table,NULL)) { 1057 psError(PS_ERR_UNKNOWN,true,"Did not expect return value true for NULL row"); 1058 psDBDropTable(dbh,table); 1059 psDBCleanup(dbh); 1060 return 6; 1061 } 1062 1063 psFree(row); 1064 psFree(invalidRow); 1065 psDBDropTable(dbh, table); 1004 1066 psFree(md); 1005 1067 psDBCleanup(dbh); 1006 1068 1007 return failed;1069 return 0; 1008 1070 } 1009 1071 -
trunk/psLib/test/dataIO/verified/tst_psDB.stderr
r4295 r4296 63 63 Failed to prepare query. Error: Table 'test.table2' doesn't exist 64 64 <DATE><TIME>|<HOST>|E|psDBInsertOneRow (FILE:LINENO) 65 Insert failed.65 Failed to insert row. 66 66 <DATE><TIME>|<HOST>|I|TPDBDropTable 67 67 Following should generate an error message for NULL database object … … 181 181 182 182 <DATE><TIME>|<HOST>|I|TPDBInsertOneRow 183 psDBInsertOneRow shall insert a row into a test table. 183 Following should generate error message for NULL database 184 <DATE><TIME>|<HOST>|E|psDBInsertRows (FILE:LINENO) 185 Invalid psDB has been specified. 186 <DATE><TIME>|<HOST>|E|psDBInsertOneRow (FILE:LINENO) 187 Failed to insert row. 188 <DATE><TIME>|<HOST>|I|TPDBInsertOneRow 189 Following should generate error message for invalid column item 190 <DATE><TIME>|<HOST>|E|psDBInsertRows (FILE:LINENO) 191 Failed to prepare query. Error: Unknown column 'key_999' in 'field list' 192 <DATE><TIME>|<HOST>|E|psDBInsertOneRow (FILE:LINENO) 193 Failed to insert row. 194 <DATE><TIME>|<HOST>|I|TPDBInsertOneRow 195 Following should generate error message for invalid table 196 <DATE><TIME>|<HOST>|E|psDBInsertRows (FILE:LINENO) 197 Failed to prepare query. Error: Table 'test.table999' doesn't exist 198 <DATE><TIME>|<HOST>|E|psDBInsertOneRow (FILE:LINENO) 199 Failed to insert row. 200 <DATE><TIME>|<HOST>|I|TPDBInsertOneRow 201 Following should generate error message for NULL row 202 <DATE><TIME>|<HOST>|E|psDBInsertOneRow (FILE:LINENO) 203 Failed to insert row. 184 204 185 205 ---> TESTPOINT PASSED (psDB{dbInsertOneRow} | tst_psDB.c)
Note:
See TracChangeset
for help on using the changeset viewer.
