Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added to support new response code 202 in webpa #68

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/wdmp_internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,6 @@ void wdmp_form_get_response(res_struct *resObj, cJSON *response)

WdmpPrint("resObj->retStatus : %d\n",resObj->retStatus[0]);
getStatusCode(&statusCode, paramCount, resObj->retStatus);

result = (char *) malloc(sizeof(char) * MAX_RESULT_LEN);

if(resObj->u.paramRes->params)
Expand Down Expand Up @@ -840,6 +839,11 @@ void wdmp_form_table_response(res_struct *resObj, cJSON *response)
*statusCode = WDMP_STATUS_ATOMIC_GET_SET_FAILED;
break;
}
else if (ret[i] == WDMP_ERR_SESSION_IN_PROGRESS)
{
*statusCode = WDMP_STATUS_PREVIOUS_REQUEST_INPROGRESS;
break;
}
else
{
*statusCode = WDMP_STATUS_GENERAL_FALURE;
Expand Down
1 change: 1 addition & 0 deletions src/wdmp_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ typedef enum
{
WDMP_STATUS_SUCCESS = 200,
WDMP_ADDROW_STATUS_SUCCESS = 201,
WDMP_STATUS_PREVIOUS_REQUEST_INPROGRESS = 202,
WDMP_STATUS_GENERAL_FALURE = 520,
WDMP_STATUS_CID_TEST_FAILED = 550,
WDMP_STATUS_CMC_TEST_FAILED = 551,
Expand Down
27 changes: 27 additions & 0 deletions tests/simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -1658,6 +1658,32 @@ void test_get_status_code()
}
}

void test_get_status_code_inprogress()
{
WDMP_RESPONSE_STATUS_CODE statusCode;
WDMP_STATUS * ret = NULL;
int paramCount = 3;

WdmpInfo("\n***************************************************** \n\n");

ret = (WDMP_STATUS *) malloc(sizeof(WDMP_STATUS)*paramCount);

ret[0] = WDMP_SUCCESS;
ret[1] = WDMP_SUCCESS;
ret[2] = WDMP_ERR_SESSION_IN_PROGRESS;

getStatusCode(&statusCode, paramCount, ret);

CU_ASSERT_EQUAL( WDMP_STATUS_PREVIOUS_REQUEST_INPROGRESS, statusCode );

WdmpInfo("statusCode : %d\n",statusCode);

if(ret)
{
free(ret);
}
}

void test_map_wdmp_status()
{
WDMP_STATUS status;
Expand Down Expand Up @@ -2554,6 +2580,7 @@ void add_response_form_suites ( CU_pSuite *suite )
CU_add_test( *suite, "Delete row Response Form", delete_row_res_form );
CU_add_test( *suite, "Table response Form", table_res_form );
CU_add_test( *suite, "Get status code", test_get_status_code );
CU_add_test( *suite, "Get status code session inprogress", test_get_status_code_inprogress );
CU_add_test( *suite, "Map wdmp status", test_map_wdmp_status );
CU_add_test( *suite, "Negative Get Response Form", neg_get_res_form );
CU_add_test( *suite, "Get Wildcard empty Response Form", get_wildcard_empty_value_res_form);
Expand Down
Loading