File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -178,10 +178,10 @@ func TestParsePortsLabel(t *testing.T) {
178
178
},
179
179
want : []cni.PortMapping {
180
180
{
181
- HostPort : 3000 ,
182
- ContainerPort : 8080 ,
181
+ HostPort : 12345 ,
182
+ ContainerPort : 10000 ,
183
183
Protocol : "tcp" ,
184
- HostIP : "127 .0.0.1 " ,
184
+ HostIP : "0 .0.0.0 " ,
185
185
},
186
186
},
187
187
wantErr : false ,
@@ -219,7 +219,7 @@ func TestParsePortsLabel(t *testing.T) {
219
219
}
220
220
if ! reflect .DeepEqual (got , tt .want ) {
221
221
if len (got ) == len (tt .want ) {
222
- if len (got ) > 1 {
222
+ if len (got ) > 0 {
223
223
var hostPorts []int32
224
224
var containerPorts []int32
225
225
for _ , value := range got {
@@ -235,6 +235,14 @@ func TestParsePortsLabel(t *testing.T) {
235
235
if (hostPorts [len (hostPorts )- 1 ] - hostPorts [0 ]) != (containerPorts [len (hostPorts )- 1 ] - containerPorts [0 ]) {
236
236
t .Errorf ("ParsePortsLabel() = %v, want %v" , got , tt .want )
237
237
}
238
+ sort .Slice (got , func (i , j int ) bool {
239
+ return got [i ].HostPort < got [j ].HostPort
240
+ })
241
+ for i := 0 ; i < len (got ); i ++ {
242
+ if got [i ].HostPort != tt .want [i ].HostPort || got [i ].ContainerPort != tt .want [i ].ContainerPort || got [i ].Protocol != tt .want [i ].Protocol || got [i ].HostIP != tt .want [i ].HostIP {
243
+ t .Errorf ("ParsePortsLabel() = %v, want %v" , got , tt .want )
244
+ }
245
+ }
238
246
}
239
247
} else {
240
248
t .Errorf ("ParsePortsLabel() = %v, want %v" , got , tt .want )
You can’t perform that action at this time.
0 commit comments