Commit acd9692e authored by M. Rehan Abbasi's avatar M. Rehan Abbasi
Browse files

add individual GET test case for /mts_sessions

parent 9e6fef68
Loading
Loading
Loading
Loading
+53 −11
Original line number Diff line number Diff line
@@ -591,11 +591,25 @@ func TestMtsSessionsListGet(t *testing.T) {
	fmt.Println("Set a scenario")
	initialiseScenario(testScenario)

	// POST
	sessionId1, _ := testMtsSessionPost(t)
	sessionId2, _ := testMtsSessionPost(t)

	// GET list
	testMtsSessionsListGet(t)

	// DELETE
	testMtsSessionDelete(t, sessionId1, true)
	testMtsSessionDelete(t, sessionId2, true)

	/******************************
	 * POST request section
	 * back to initial state section
	 ******************************/
	_, _ = testMtsSessionPost(t)
	_, _ = testMtsSessionPost(t)

	terminateScenario()
}

func testMtsSessionsListGet(t *testing.T) {

	/******************************
	 * expected response section
@@ -611,21 +625,49 @@ func TestMtsSessionsListGet(t *testing.T) {
		t.Fatalf("Failed to get expected response")
	}

	var mtsSessionInfoList []mts.MtsSessionInfo
	err = json.Unmarshal([]byte(rr), &mtsSessionInfoList)
	var responseBody []mts.MtsSessionInfo
	err = json.Unmarshal([]byte(rr), &responseBody)
	if err != nil {
		t.Fatalf("Failed to get expected response")
	}

	if len(mtsSessionInfoList) != nbExpectedMtsSessionInfo {
	if len(responseBody) != nbExpectedMtsSessionInfo {
		t.Fatalf("Failed to get expected response, expected none")
	}
}

func testMtsSessionsGet(t *testing.T, sessionId string, expectedResponse string) {

	/******************************
	 * back to initial state section
	 * expected response section
	 ******************************/
	//passed as a parameter since a POST had to be sent first

	terminateScenario()
	/******************************
	 * request vars section
	 ******************************/
	vars := make(map[string]string)
	vars["sessionId"] = sessionId

	/******************************
	 * request execution section
	 ******************************/
	var err error
	if expectedResponse == "" {
		_, err = sendRequest(http.MethodGet, "/mts/v1/mts_sessions", nil, vars, nil, http.StatusNotFound, mts.MtsSessionGET)
		if err != nil {
			t.Fatalf("Failed to get expected response")
		}
	} else {
		rr, err := sendRequest(http.MethodGet, "/mts/v1/mts_sessions", nil, vars, nil, http.StatusOK, mts.MtsSessionGET)
		if err != nil {
			t.Fatalf("Failed to get expected response")
		}

		if rr != expectedResponse {
			t.Fatalf("Failed to get expected response")
		}
	}
}

func testMtsSessionDelete(t *testing.T, sessionId string, expectSuccess bool) {
@@ -653,7 +695,7 @@ func testMtsSessionDelete(t *testing.T, sessionId string, expectSuccess bool) {
	}
}

func TestMtsSessionComplete(t *testing.T) {
func TestSuccessMtsSession(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())

@@ -675,9 +717,9 @@ func TestMtsSessionComplete(t *testing.T) {
	updateScenario("mobility1")

	// POST
	sessionId, _ := testMtsSessionPost(t)
	sessionId, expectedGetResp := testMtsSessionPost(t)
	// GET
	// TODO
	testMtsSessionsGet(t, sessionId, expectedGetResp)
	// PUT
	// TODO
	// DELETE