Correct regexp check in IsNodeUnmanagedByProvider

The IsNodeUnmanagedByProviderID function in the Azure Cloud Provider should
return the inverse of regexp.Match in the case of checking the ProviderID
This commit is contained in:
Marc Sensenich
2018-10-23 16:26:00 +00:00
parent 8be25aaade
commit 0bcbfca9cd
2 changed files with 36 additions and 2 deletions

View File

@@ -107,3 +107,38 @@ func TestIsNodeUnmanaged(t *testing.T) {
assert.Equal(t, test.expected, real, test.name)
}
}
func TestIsNodeUnmanagedByProviderID(t *testing.T) {
tests := []struct {
providerID string
expected bool
name string
}{
{
providerID: CloudProviderName + ":///subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroupName/providers/Microsoft.Compute/virtualMachines/k8s-agent-AAAAAAAA-0",
expected: false,
},
{
providerID: CloudProviderName + "://",
expected: true,
},
{
providerID: ":///subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroupName/providers/Microsoft.Compute/virtualMachines/k8s-agent-AAAAAAAA-0",
expected: true,
},
{
providerID: "aws:///subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroupName/providers/Microsoft.Compute/virtualMachines/k8s-agent-AAAAAAAA-0",
expected: true,
},
{
providerID: "k8s-agent-AAAAAAAA-0",
expected: true,
},
}
az := getTestCloud()
for _, test := range tests {
isUnmanagedNode := az.IsNodeUnmanagedByProviderID(test.providerID)
assert.Equal(t, test.expected, isUnmanagedNode, test.providerID)
}
}