Skip to content

Commit c5b18be

Browse files
committed
added extra unit test cases
1 parent ae341d5 commit c5b18be

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

npm/pkg/dataplane/dataplane_windows.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ func removeCommonEndpoints(endpoints, endpointsAttached *[]hcn.HostComputeEndpoi
390390
}
391391

392392
// Append endpoints from larger list and remove common IDs from map
393-
var result []hcn.HostComputeEndpoint
393+
result := []hcn.HostComputeEndpoint{}
394394
for i := 0; i < len(*largerEndpointsList); i++ {
395395
ep := (*largerEndpointsList)[i]
396396
result = append(result, ep)

npm/pkg/dataplane/dataplane_windows_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,24 @@ func TestRemoveCommonEndpoints(t *testing.T) {
119119
endpointsAttached: []hcn.HostComputeEndpoint{{Id: "567890"}, {Id: "789012"}, {Id: "123456"}},
120120
expected: []hcn.HostComputeEndpoint{{Id: "456901"}, {Id: "560971"}, {Id: "123456"}, {Id: "789012"}, {Id: "567890"}},
121121
},
122+
{
123+
name: "no values",
124+
endpoints: []hcn.HostComputeEndpoint{},
125+
endpointsAttached: []hcn.HostComputeEndpoint{},
126+
expected: []hcn.HostComputeEndpoint{},
127+
},
128+
{
129+
name: "1 value - same",
130+
endpoints: []hcn.HostComputeEndpoint{{Id: "456901"}},
131+
endpointsAttached: []hcn.HostComputeEndpoint{{Id: "456901"}},
132+
expected: []hcn.HostComputeEndpoint{{Id: "456901"}},
133+
},
134+
{
135+
name: "1 value - different",
136+
endpoints: []hcn.HostComputeEndpoint{{Id: "456901"}},
137+
endpointsAttached: []hcn.HostComputeEndpoint{{Id: "456990"}},
138+
expected: []hcn.HostComputeEndpoint{{Id: "456990"}, {Id: "456901"}},
139+
},
122140
}
123141
for _, tt := range tests {
124142
tt := tt

0 commit comments

Comments
 (0)