language-extensions/R/test/src/RExtensionInitSessionTests.cpp
//----------------------------------------------------------------------------------------------
// Name: InitSessionTest
//
// Description:
//  Tests InitSession() API with valid values.
//
InitSessionTest
Description:
Tests InitSession() API with valid values.
InitSessionTest Description : Tests InitSession () API with valid values .
TEST_F(RExtensionApiTests, InitSessionTest)
	{
		SQLRETURN result = SQL_ERROR;
		result = (*sm_initSessionFuncPtr)(
			*m_sessionId,
			m_taskId,
			m_numTasks,
			m_script,
			m_scriptString.length(),
			m_inputSchemaColumnsNumber,
			m_parametersNumber,
			m_inputDataName,
			m_inputDataNameString.length(),
			m_outputDataName,
			m_outputDataNameString.length());
		EXPECT_EQ(result, SQL_SUCCESS);
		result = (*sm_initSessionFuncPtr)(
			*m_sessionId,
			m_taskId,
			m_numTasks,
			m_script,
			m_scriptString.length(),
			m_inputSchemaColumnsNumber,
			m_parametersNumber,
			m_inputDataName,
			m_inputDataNameString.length(),
			m_outputDataName,
			m_outputDataNameString.length());
		EXPECT_EQ(result, SQL_ERROR);
		SQLGUID sessionId = { 0, 0, 1, {1} };
		 Try cleanup without first initializing a different session should still pass
		 since while cleaning up we can't differentiate if the cleanup is for
		 library session or not. For library sessions, we don't do initialization.
		result = (*sm_cleanupSessionFuncPtr)(
			sessionId,
			m_taskId);
		EXPECT_EQ(result, SQL_SUCCESS);
		 Initialize the different session; make sure this also inits independently
		 even though previous session is still in progress.
		result = (*sm_initSessionFuncPtr)(
			sessionId,
			m_taskId,
			m_numTasks,
			m_script,
			m_scriptString.length(),
			m_inputSchemaColumnsNumber,
			m_parametersNumber,
			m_inputDataName,
			m_inputDataNameString.length(),
			m_outputDataName,
			m_outputDataNameString.length());
		EXPECT_EQ(result, SQL_SUCCESS);
		result = (*sm_cleanupSessionFuncPtr)(
			sessionId,
			m_taskId);
		EXPECT_EQ(result, SQL_SUCCESS);
	}
TEST_F ( RExtensionApiTests , InitSessionTest ) { SQLRETURN result = SQL_ERROR ; result = ( * sm_initSessionFuncPtr ) ( * m_sessionId , m_taskId , m_numTasks , m_script , m_scriptString . length ( ) , m_inputSchemaColumnsNumber , m_parametersNumber , m_inputDataName , m_inputDataNameString . length ( ) , m_outputDataName , m_outputDataNameString . length ( ) ) ; EXPECT_EQ ( result , SQL_SUCCESS ) ; result = ( * sm_initSessionFuncPtr ) ( * m_sessionId , m_taskId , m_numTasks , m_script , m_scriptString . length ( ) , m_inputSchemaColumnsNumber , m_parametersNumber , m_inputDataName , m_inputDataNameString . length ( ) , m_outputDataName , m_outputDataNameString . length ( ) ) ; EXPECT_EQ ( result , SQL_ERROR ) ; SQLGUID sessionId = { 0 , 0 , 1 , { 1 } } ; result = ( * sm_cleanupSessionFuncPtr ) ( sessionId , m_taskId ) ; EXPECT_EQ ( result , SQL_SUCCESS ) ; result = ( * sm_initSessionFuncPtr ) ( sessionId , m_taskId , m_numTasks , m_script , m_scriptString . length ( ) , m_inputSchemaColumnsNumber , m_parametersNumber , m_inputDataName , m_inputDataNameString . length ( ) , m_outputDataName , m_outputDataNameString . length ( ) ) ; EXPECT_EQ ( result , SQL_SUCCESS ) ; result = ( * sm_cleanupSessionFuncPtr ) ( sessionId , m_taskId ) ; EXPECT_EQ ( result , SQL_SUCCESS ) ; }
Name: InitSessionTest
Description:
Tests InitSession() API with valid values.
Name : InitSessionTest Description : Tests InitSession () API with valid values .
// Try to reinitialize with the same session Id should fail // // Try cleanup without first initializing a different session should still pass // since while cleaning up we can't differentiate if the cleanup is for // library session or not. For library sessions, we don't do initialization. // // Initialize the different session; make sure this also inits independently // even though previous session is still in progress. //