mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
Add a unit test for newAzureResourceFromID in discovery/azure/azure.go. (#7484)
This PR is about adding a unit test for newAzureResourceFromID in discovery/azure/azure.go. Signed-off-by: Hu Shuai <hus.fnst@cn.fujitsu.com>
This commit is contained in:
parent
f50786bcd1
commit
a94b570dc6
|
@ -201,3 +201,24 @@ func TestMapFromVMScaleSetVMWithTags(t *testing.T) {
|
||||||
t.Errorf("Expected %v got %v", expectedVM, actualVM)
|
t.Errorf("Expected %v got %v", expectedVM, actualVM)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestNewAzureResourceFromID(t *testing.T) {
|
||||||
|
for _, tc := range []struct {
|
||||||
|
id string
|
||||||
|
expected azureResource
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
id: "/a/b/c/group/d/e/f/name",
|
||||||
|
expected: azureResource{"name", "group"},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "/a/b/c/group/d/e/f/name/g/h",
|
||||||
|
expected: azureResource{"name", "group"},
|
||||||
|
},
|
||||||
|
} {
|
||||||
|
actual, _ := newAzureResourceFromID(tc.id, nil)
|
||||||
|
if !reflect.DeepEqual(tc.expected, actual) {
|
||||||
|
t.Errorf("Expected %v got %v", tc.expected, actual)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue