diff --git a/govc/test/library.bats b/govc/test/library.bats index 8b761c8ed..24b2a21fb 100755 --- a/govc/test/library.bats +++ b/govc/test/library.bats @@ -394,7 +394,7 @@ EOF govc library.subscriber.ls govc-pub-vmtx | grep govc-sub-vmtx-$ds2 # Expect 1 VM: govc-pub-vmtx/ttylinux-pc_i486-16.1 - govc find vm -type f -name govc-* | xargs -n1 -r govc find -type m + govc find vm -type f -name govc-* | $xargs -n1 -r govc find -type m # Publish entire library govc library.publish govc-pub-vmtx @@ -403,7 +403,7 @@ EOF govc library.publish govc-pub-vmtx/ttylinux-pc_i486-16.1 # Expect 2 more VMs: govc-sub-vmtx-{$ds1,$ds2} - govc find vm -type f -name govc-* | xargs -n1 govc find -type m + govc find vm -type f -name govc-* | $xargs -n1 govc find -type m for ds in $ds1 $ds2 ; do govc vm.clone -link -vm govc-sub-vmtx-$ds/ttylinux-pc_i486-16.1 -ds $ds -pool $pool -folder govc-sub-vmtx-$ds ttylinux diff --git a/govc/test/network.bats b/govc/test/network.bats index a5155dd45..367255f13 100755 --- a/govc/test/network.bats +++ b/govc/test/network.bats @@ -140,7 +140,7 @@ load test_helper # validate each NIC has a unique MAC macs=$(govc device.info -vm "$vm" -json ethernet-* | jq -r .Devices[].MacAddress | uniq | wc -l) - [ "$macs" = "2" ] + assert_equal 2 "$macs" } @test "network flag required" { diff --git a/govc/test/test_helper.bash b/govc/test/test_helper.bash index 371c1819f..843c6d574 100644 --- a/govc/test/test_helper.bash +++ b/govc/test/test_helper.bash @@ -206,7 +206,7 @@ assert_failure() { } assert_equal() { - if [ "$1" != "$2" ]; then + if [ "$(collapse_ws "$1")" != "$(collapse_ws "$2")" ]; then { echo "expected: $1" echo "actual: $2" } | flunk diff --git a/govc/test/vcsim.bats b/govc/test/vcsim.bats index 315a05dd9..05cb3ca9d 100755 --- a/govc/test/vcsim.bats +++ b/govc/test/vcsim.bats @@ -67,7 +67,7 @@ load test_helper run govc object.collect -s -type h host/DC0_H0 summary.config.port assert_success "$port" ports=$(govc object.collect -s -type h / summary.config.port | uniq -u | wc -l) - [ "$ports" = "0" ] # all host ports should be the same value + assert_equal 0 "$ports" # all host ports should be the same value vcsim_stop @@ -75,8 +75,8 @@ load test_helper hosts=$(curl -sk "https://$url/debug/vars" | jq .vcsim.Model.Host) ports=$(govc object.collect -s -type h / summary.config.port | uniq -u | wc -l) - [ "$ports" = "$hosts" ] # all host ports should be unique - [[ "$ports" != *$port* ]] # host ports should not include vcsim port + assert_equal "$ports" "$hosts" # all host ports should be unique + grep -v "$port" <<<"$ports" # host ports should not include vcsim port } @test "vcsim set vm properties" { @@ -171,13 +171,13 @@ EOF assert_success "$(printf "265104de-1472-547c-b873-6dc7883fb6cb\nb4689bed-97f0-5bcd-8a4c-07477cc8f06f")" dups=$(govc object.collect -s -type m / config.uuid | sort | uniq -d | wc -l) - [ "$dups" = "0" ] + assert_equal 0 "$dups" run govc object.collect -s host/DC0_H0/DC0_H0 summary.hardware.uuid assert_success dcf7fb3c-4a1c-5a05-b730-5e09f3704e2f dups=$(govc object.collect -s -type m / summary.hardware.uuid | sort | uniq -d | wc -l) - [ "$dups" = "0" ] + assert_equal 0 "$dups" run govc vm.create foo.yakity assert_success @@ -281,7 +281,7 @@ docker_name() { assert_success ip=$(govc object.collect -s vm/$vm guest.ipAddress) - run curl -f "http://$ip/vcsim.bats" + run docker run --rm curlimages/curl curl -f "http://$ip/vcsim.bats" assert_success # test suspend/resume