IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 4296


Ignore:
Timestamp:
Jun 17, 2005, 11:32:44 AM (21 years ago)
Author:
evanalst
Message:

Update test case for psDBInsertOneRow.

Location:
trunk/psLib/test/dataIO
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/test/dataIO/tst_psDB.c

    r4295 r4296  
    99 *  @author Aaron Culliney, MHPCC
    1010 *
    11  *  @version $Revision: 1.20 $ $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 $
    1313 *
    1414 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    6161    const char *key5, const char *comm5, psS32  val5);
    6262static psMetadata *_get_row( void );
     63static psMetadata *_get_invalid_row( void );
    6364static psMetadata *_get_where( void );
    6465static psMetadata *_get_update_values(const char *val0, psS32 val1, psF32 val2, psF64 val3, psBool val4);
     
    232233}
    233234
     235psMetadata *_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
    234246psMetadata *_get_where( void )
    235247{
     
    979991}
    980992
    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 ...
    982994psS32 TPDBInsertOneRow( void )
    983995{
    984     psS32 failed = 0;
    985996    psDB *dbh = NULL;
    986997    const char* table = "table6";
     998    psMetadata *invalidRow = NULL;
     999
     1000    // Create table definition metadata
    9871001    psMetadata *row=NULL, *md = _get_CreateTableMetadata();
    9881002
     1003    // Initialize database connection
    9891004    dbh = _init_psDB();
    9901005    if (dbh == NULL) {
     1006        psError(PS_ERR_UNKNOWN,true,"Did not expect return NULL for database initialization");
    9911007        return 1;
    9921008    }
    9931009
    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);
    10041066    psFree(md);
    10051067    psDBCleanup(dbh);
    10061068
    1007     return failed;
     1069    return 0;
    10081070}
    10091071
  • trunk/psLib/test/dataIO/verified/tst_psDB.stderr

    r4295 r4296  
    6363    Failed to prepare query.  Error: Table 'test.table2' doesn't exist
    6464<DATE><TIME>|<HOST>|E|psDBInsertOneRow (FILE:LINENO)
    65     Insert failed.
     65    Failed to insert row.
    6666<DATE><TIME>|<HOST>|I|TPDBDropTable
    6767    Following should generate an error message for NULL database object
     
    181181
    182182<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.
    184204
    185205---> TESTPOINT PASSED (psDB{dbInsertOneRow} | tst_psDB.c)
Note: See TracChangeset for help on using the changeset viewer.