Fix unit tests

This commit is contained in:
Pengfei Ni 2017-12-13 14:21:57 +08:00
parent 86111df41d
commit 97fab90cd5
3 changed files with 7 additions and 4 deletions

View File

@ -24,6 +24,7 @@ go_library(
"azure_storageaccount.go", "azure_storageaccount.go",
"azure_util.go", "azure_util.go",
"azure_util_vmss.go", "azure_util_vmss.go",
"azure_vmsets.go",
"azure_wrap.go", "azure_wrap.go",
"azure_zones.go", "azure_zones.go",
], ],

View File

@ -870,6 +870,7 @@ func getTestCloud() (az *Cloud) {
az.SecurityGroupsClient = newFakeAzureNSGClient() az.SecurityGroupsClient = newFakeAzureNSGClient()
az.VirtualMachinesClient = newFakeAzureVirtualMachinesClient() az.VirtualMachinesClient = newFakeAzureVirtualMachinesClient()
az.InterfacesClient = newFakeAzureInterfacesClient() az.InterfacesClient = newFakeAzureInterfacesClient()
az.vmSet = newAvailabilitySet(az)
return az return az
} }
@ -1631,7 +1632,8 @@ func TestDecodeInstanceInfo(t *testing.T) {
} }
} }
func TestSplitProviderID(t *testing.T) { func TestGetNodeNameByProviderID(t *testing.T) {
az := getTestCloud()
providers := []struct { providers := []struct {
providerID string providerID string
name types.NodeName name types.NodeName
@ -1666,7 +1668,7 @@ func TestSplitProviderID(t *testing.T) {
} }
for _, test := range providers { for _, test := range providers {
name, err := splitProviderID(test.providerID) name, err := az.vmSet.GetNodeNameByProviderID(test.providerID)
if (err != nil) != test.fail { if (err != nil) != test.fail {
t.Errorf("Expected to failt=%t, with pattern %v", test.fail, test) t.Errorf("Expected to failt=%t, with pattern %v", test.fail, test)
} }

View File

@ -23,7 +23,7 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )
func TestGetVmssInstanceID(t *testing.T) { func TestGetScaleSetVMInstanceID(t *testing.T) {
tests := []struct { tests := []struct {
msg string msg string
machineName string machineName string
@ -43,7 +43,7 @@ func TestGetVmssInstanceID(t *testing.T) {
} }
for i, test := range tests { for i, test := range tests {
instanceID, err := getVmssInstanceID(test.machineName) instanceID, err := getScaleSetVMInstanceID(test.machineName)
if test.expectError { if test.expectError {
assert.Error(t, err, fmt.Sprintf("TestCase[%d]: %s", i, test.msg)) assert.Error(t, err, fmt.Sprintf("TestCase[%d]: %s", i, test.msg))
} else { } else {