@@ -2,7 +2,6 @@ package dataplane
22
33import (
44 "fmt"
5- "reflect"
65 "sync"
76 "testing"
87 "time"
@@ -12,6 +11,7 @@ import (
1211 "github.com/Azure/azure-container-networking/npm/pkg/dataplane/ipsets"
1312 dptestutils "github.com/Azure/azure-container-networking/npm/pkg/dataplane/testutils"
1413 "github.com/Microsoft/hcsshim/hcn"
14+ "github.com/google/go-cmp/cmp"
1515 "github.com/pkg/errors"
1616 "github.com/stretchr/testify/require"
1717)
@@ -99,19 +99,19 @@ func TestRemoveCommonEndpoints(t *testing.T) {
9999 name : "1 value same" ,
100100 endpoints : []hcn.HostComputeEndpoint {{Id : "456901" }, {Id : "123456" }, {Id : "560971" }},
101101 endpointsAttached : []hcn.HostComputeEndpoint {{Id : "567890" }, {Id : "123456" }, {Id : "789012" }},
102- expected : []hcn.HostComputeEndpoint {{Id : "567890 " }, {Id : "123456" }, {Id : "789012 " }, {Id : "456901 " }, {Id : "560971 " }},
102+ expected : []hcn.HostComputeEndpoint {{Id : "456901 " }, {Id : "123456" }, {Id : "560971 " }, {Id : "567890 " }, {Id : "789012 " }},
103103 },
104104 {
105105 name : "no values same" ,
106106 endpoints : []hcn.HostComputeEndpoint {{Id : "456901" }, {Id : "560971" }},
107107 endpointsAttached : []hcn.HostComputeEndpoint {{Id : "567890" }, {Id : "789012" }},
108- expected : []hcn.HostComputeEndpoint {{Id : "567890 " }, {Id : "789012 " }, {Id : "456901 " }, {Id : "560971 " }},
108+ expected : []hcn.HostComputeEndpoint {{Id : "456901 " }, {Id : "560971 " }, {Id : "567890 " }, {Id : "789012 " }},
109109 },
110110 {
111111 name : "1 value same" ,
112112 endpoints : []hcn.HostComputeEndpoint {{Id : "456901" }, {Id : "123456" }, {Id : "560971" }},
113113 endpointsAttached : []hcn.HostComputeEndpoint {{Id : "567890" }, {Id : "123456" }, {Id : "789012" }},
114- expected : []hcn.HostComputeEndpoint {{Id : "567890 " }, {Id : "123456" }, {Id : "789012 " }, {Id : "456901 " }, {Id : "560971 " }},
114+ expected : []hcn.HostComputeEndpoint {{Id : "456901 " }, {Id : "123456" }, {Id : "560971 " }, {Id : "567890 " }, {Id : "789012 " }},
115115 },
116116 {
117117 name : "two values same" ,
@@ -142,14 +142,10 @@ func TestRemoveCommonEndpoints(t *testing.T) {
142142 tt := tt
143143
144144 t .Run (tt .name , func (t * testing.T ) {
145- result := removeCommonEndpoints (& tt .endpoints , & tt .endpointsAttached )
146- // Use reflect.DeepEqual as a backup if require.Equal doesn't work as expected
147- if ! reflect .DeepEqual (tt .expected , result ) {
145+ result := GetUniqueEndpoints (tt .endpoints , tt .endpointsAttached )
146+ if ! cmp .Equal (tt .expected , result ) {
148147 t .Errorf ("Test %s failed: expected %v, got %v" , tt .name , tt .expected , result )
149148 }
150-
151- // Or, if require.Equal works fine, it will display a descriptive error message
152- require .Equal (t , tt .expected , result , "expected array equals result" )
153149 })
154150 }
155151}
0 commit comments