Skip to content

Commit

Permalink
Added test cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
anthony-tuininga committed May 28, 2021
1 parent 3264f7a commit 9f4744f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
2 changes: 1 addition & 1 deletion doc/src/releasenotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Version 4.2.1 (TBD)
#) All errors identified as causing a dead connection now populate
:member:`dpiErrorInfo.sqlState` with the value `01002` instead of only a
hard-coded list of errors.
#) Improved documentation.
#) Improved documentation and the test suite.


Version 4.2 (May 18, 2021)
Expand Down
29 changes: 26 additions & 3 deletions test/TestConn.c
Original file line number Diff line number Diff line change
Expand Up @@ -687,12 +687,13 @@ int dpiTest_315_createAndCloseTwice(dpiTestCase *testCase,

//-----------------------------------------------------------------------------
// dpiTest_316_verifySetCallTimeout()
// Call dpiConn_setCallTimeout() and verify it works as expected by
// returning a timeout error (DPI-1067).
// Call dpiConn_setCallTimeout() and verify it works as expected by returning
// a timeout error or connection closed error (DPI-1067/DPI-1080).
//-----------------------------------------------------------------------------
int dpiTest_316_verifySetCallTimeout(dpiTestCase *testCase,
dpiTestParams *params)
{
const char *expectedErrors[] = { "DPI-1067:", "DPI-1080:", NULL };
const char *sql = "begin dbms_session.sleep(10); end;";
uint32_t setTimeout = 250;
dpiConn *conn;
Expand All @@ -707,7 +708,7 @@ int dpiTest_316_verifySetCallTimeout(dpiTestCase *testCase,
if (dpiConn_prepareStmt(conn, 0, sql, strlen(sql), NULL, 0, &stmt) < 0)
return dpiTestCase_setFailedFromError(testCase);
dpiStmt_execute(stmt, DPI_MODE_EXEC_DEFAULT, NULL);
if (dpiTestCase_expectError(testCase, "DPI-1067:") < 0)
if (dpiTestCase_expectAnyError(testCase, expectedErrors) < 0)
return DPI_FAILURE;
if (dpiStmt_release(stmt) < 0)
return dpiTestCase_setFailedFromError(testCase);
Expand Down Expand Up @@ -739,6 +740,26 @@ int dpiTest_317_verifySetAndGetCallTimeout(dpiTestCase *testCase,
}


//-----------------------------------------------------------------------------
// dpiTest_318_verifyConnFailure()
// Verify that dpiConn_create() fails with ORA-12154 error when connection
// failure occurs.
//-----------------------------------------------------------------------------
int dpiTest_318_verifyConnFailure(dpiTestCase *testCase,
dpiTestParams *params)
{
dpiContext *context;
dpiConn *conn;

dpiTestSuite_getContext(&context);
dpiConn_create(context, params->mainUserName,
params->mainUserNameLength, params->mainPassword,
params->mainPasswordLength, "invalid/orclpdb",
strlen("invalid/orclpdb"), NULL, NULL, &conn);
return dpiTestCase_expectError(testCase, "ORA-12154:");
}


//-----------------------------------------------------------------------------
// main()
//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -781,5 +802,7 @@ int main(int argc, char **argv)
"verify dpiConn_setCallTimeout()");
dpiTestSuite_addCase(dpiTest_317_verifySetAndGetCallTimeout,
"verify dpiConn_setCallTimeout()/dpiConn_getCallTimeout()");
dpiTestSuite_addCase(dpiTest_318_verifyConnFailure,
"verify dpiConn_create() fails with ORA error during conn failure");
return dpiTestSuite_run();
}

0 comments on commit 9f4744f

Please sign in to comment.