Fix unit tests for new interfaces

This commit is contained in:
Pengfei Ni 2018-05-08 22:42:58 +08:00
parent f427d279fe
commit d32e73aba9
2 changed files with 6 additions and 11 deletions

View File

@ -826,7 +826,7 @@ func (fDC *fakeDisksClient) Get(ctx context.Context, resourceGroupName string, d
}
type fakeVMSet struct {
NodeToIP map[string]map[string]string
NodeToIP map[string]string
Err error
}
@ -838,15 +838,12 @@ func (f *fakeVMSet) GetInstanceTypeByNodeName(name string) (string, error) {
return "", fmt.Errorf("unimplemented")
}
func (f *fakeVMSet) GetIPByNodeName(name, vmSetName string) (string, string, error) {
nodes, found := f.NodeToIP[vmSetName]
if !found {
return "", "", fmt.Errorf("not found")
}
ip, found := nodes[name]
func (f *fakeVMSet) GetIPByNodeName(name string) (string, string, error) {
ip, found := f.NodeToIP[name]
if !found {
return "", "", fmt.Errorf("not found")
}
return ip, "", nil
}

View File

@ -94,10 +94,8 @@ func TestCreateRoute(t *testing.T) {
route := cloudprovider.Route{TargetNode: "node", DestinationCIDR: "1.2.3.4/24"}
nodeIP := "2.4.6.8"
fakeVM.NodeToIP = map[string]map[string]string{
"": {
"node": nodeIP,
},
fakeVM.NodeToIP = map[string]string{
"node": nodeIP,
}
err := cloud.CreateRoute(context.TODO(), "cluster", "unused", &route)