nit: Fix invokeStaleDummyVMTestWithStoragePolicy()

There were nits in invokeStaleDummyVMTestWithStoragePolicy() like
- The error message didn't contain necessary space
- IsVMPresent() can return an error, but lack of the error handling
- IsVMPresent() returns true/false, but didn't use ExpectEqual() and
  less code readability

This fixes those things.
This commit is contained in:
Kenichi Omichi 2020-06-25 04:46:44 +00:00
parent 3c31a0026a
commit d964569e1e

View File

@ -335,8 +335,9 @@ func invokeStaleDummyVMTestWithStoragePolicy(client clientset.Interface, masterN
fnvHash := fnv.New32a()
fnvHash.Write([]byte(vmName))
dummyVMFullName := dummyVMPrefixName + "-" + fmt.Sprint(fnvHash.Sum32())
errorMsg := "Dummy VM - " + vmName + "is still present. Failing the test.."
errorMsg := "Dummy VM - " + vmName + " is still present. Failing the test.."
nodeInfo := TestContext.NodeMapper.GetNodeInfo(masterNode)
isVMPresentFlag, _ := nodeInfo.VSphere.IsVMPresent(dummyVMFullName, nodeInfo.DataCenterRef)
framework.ExpectNotEqual(isVMPresentFlag, true, errorMsg)
isVMPresentFlag, err := nodeInfo.VSphere.IsVMPresent(dummyVMFullName, nodeInfo.DataCenterRef)
framework.ExpectNoError(err)
framework.ExpectEqual(isVMPresentFlag, false, errorMsg)
}