Skip to content

Commit 7dc6a11

Browse files
committed
add a test
1 parent 5dd0bea commit 7dc6a11

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

cns/NetworkContainerContract.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
const (
2020
SetOrchestratorType = "/network/setorchestratortype"
2121
GetHomeAz = "/homeaz"
22+
GetNCList = "/nclist"
2223
GetVMUniqueID = "/metadata/vmuniqueid"
2324
CreateOrUpdateNetworkContainer = "/network/createorupdatenetworkcontainer"
2425
DeleteNetworkContainer = "/network/deletenetworkcontainer"
@@ -40,7 +41,6 @@ const (
4041
NumberOfCPUCores = NumberOfCPUCoresPath
4142
NMAgentSupportedAPIs = NmAgentSupportedApisPath
4243
EndpointAPI = EndpointPath
43-
GetNCList = "/nclist"
4444
)
4545

4646
// NetworkContainer Prefixes

cns/api.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const (
2828
CreateHostNCApipaEndpointPath = "/network/createhostncapipaendpoint"
2929
DeleteHostNCApipaEndpointPath = "/network/deletehostncapipaendpoint"
3030
NmAgentSupportedApisPath = "/network/nmagentsupportedapis"
31+
NMAgentGetNCListAPIPath = "/nclist"
3132
V1Prefix = "/v0.1"
3233
V2Prefix = "/v0.2"
3334
EndpointPath = "/network/endpoints/"

cns/restserver/api_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,6 +1302,31 @@ func TestNmAgentSupportedApisHandler(t *testing.T) {
13021302
fmt.Printf("nmAgentSupportedApisHandler Responded with %+v\n", nmAgentSupportedApisResponse)
13031303
}
13041304

1305+
func TestNMAgentNCListHandler(t *testing.T) {
1306+
fmt.Println("Test: nmAgentNCListHandler")
1307+
var (
1308+
err error
1309+
req *http.Request
1310+
)
1311+
1312+
req, err = http.NewRequest(http.MethodGet, cns.NMAgentGetNCListAPIPath, nil)
1313+
if err != nil {
1314+
t.Fatal(err)
1315+
}
1316+
1317+
w := httptest.NewRecorder()
1318+
mux.ServeHTTP(w, req)
1319+
var nmAgentNCListResponse cns.NCListResponse
1320+
1321+
err = decodeResponse(w, &nmAgentNCListResponse)
1322+
if err != nil || nmAgentNCListResponse.Response.ReturnCode != 0 {
1323+
t.Errorf("nmAgentNCListHandler failed with response %+v", nmAgentNCListResponse)
1324+
}
1325+
1326+
fmt.Printf("nmAgentNCListHandler responded with %+v\n", nmAgentNCListResponse)
1327+
require.Len(t, nmAgentNCListResponse.NCList, 0)
1328+
}
1329+
13051330
// Testing GetHomeAz API handler, return UnsupportedVerb if http method is not supported
13061331
func TestGetHomeAz_UnsupportedHttpMethod(t *testing.T) {
13071332
req, err := http.NewRequestWithContext(context.TODO(), http.MethodPost, cns.GetHomeAz, http.NoBody)

0 commit comments

Comments
 (0)