mirror of
https://github.com/prometheus/prometheus
synced 2025-01-12 09:40:00 +00: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)
|
||||
}
|
||||
}
|
||||
|
||||
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 New Issue
Block a user