test(globals): Fix failing tests
This fixes test failures introduced in a recent refactoring.
Blame: 0bf60996c5
This commit is contained in:
2 files changed
+7
-2
No files matched your search
+5
-1
@@ -311,7 +311,11 @@ var resourceTypeToPrefixes map[resource.Type][]string = func() map[resource.Type
|
||||
func ResourceInfoFromPrefix(in string) ResourceInfo {
|
||||
// If full ID, trim to just prefix
|
||||
in, _, _ = strings.Cut(in, "_")
|
||||
return prefixToResourceType[in]
|
||||
res, ok := prefixToResourceType[in]
|
||||
if !ok {
|
||||
return ResourceInfo{Type: resource.Unknown}
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
// ResourcePrefixesFromType returns the known prefixes for a given type; if a
|
||||
|
||||
@@ -20,9 +20,10 @@ func TestResourceInfoFromPrefix(t *testing.T) {
|
||||
JsonCredentialPrefix: resource.Credential,
|
||||
}
|
||||
|
||||
assert.Equal(t, resource.Unknown, ResourceInfoFromPrefix("foobar").Type)
|
||||
for prefix, typ := range vals {
|
||||
assert.Equal(t, typ, ResourceInfoFromPrefix(prefix).Type)
|
||||
assert.Equal(t, typ, ResourceInfoFromPrefix(fmt.Sprintf("%s_foobar", prefix)).Type)
|
||||
assert.Equal(t, resource.Unknown, ResourceInfoFromPrefix(fmt.Sprintf("%sfoobar", prefix)))
|
||||
assert.Equal(t, resource.Unknown, ResourceInfoFromPrefix(fmt.Sprintf("%sfoobar", prefix)).Type)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user