Skip to content

Commit

Permalink
add test for isNetworkNotFound
Browse files Browse the repository at this point in the history
  • Loading branch information
spowelljr committed Sep 29, 2023
1 parent 25c1f32 commit c1ea47c
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions pkg/drivers/kic/oci/network_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,65 @@ func TestPodmanInspect(t *testing.T) {
})
}
}

func TestIsNetworkNotFound(t *testing.T) {
tests := []struct {
output string
isNotFound bool
}{
{"Error: No such network: cat", true},
{"Error response from daemon: network cat not found", true},
{`[
{
"Name": "abcde123",
"Id": "4683c88eb412f2744e9763a4bebcb5e3b73a11dbcc79d6d9ab64ab2f10e08faa",
"Created": "2023-09-29T17:12:11.774716834Z",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": {},
"Config": [
{
"Subnet": "192.168.49.0/24",
"Gateway": "192.168.49.1"
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {
"b6954f226ccfdb7d190e3792be8d569e4bc5e3c44833d9e274835212fca4f4d2": {
"Name": "p2",
"EndpointID": "30fd6525dab2b0a4f1953a3c8cae7485be272e09938dffe3d6de81e84c574826",
"MacAddress": "02:42:c0:a8:31:02",
"IPv4Address": "192.168.49.2/24",
"IPv6Address": ""
}
},
"Options": {
"--icc": "",
"--ip-masq": "",
"com.docker.network.driver.mtu": "65535"
},
"Labels": {
"created_by.minikube.sigs.k8s.io": "true",
"name.minikube.sigs.k8s.io": "minikube"
}
}
]`, false},
}

for _, tc := range tests {
got := isNetworkNotFound(tc.output)
if got != tc.isNotFound {
t.Errorf("isNetworkNotFound(%s) = %t; want = %t", tc.output, got, tc.isNotFound)
}
}
}

0 comments on commit c1ea47c

Please sign in to comment.