Revert "test(globals): Fix failing tests" (#3983)

This reverts commit 274aca755f.
This commit is contained in:
Jeff Mitchell authored and GitHub committed 2023-11-02 13:12:20 -04:00
1 parent 274aca755f
commit 66c0f152d9
2 files changed
+2 -7

No files matched your search

+1 -5
View File
@@ -311,11 +311,7 @@ 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, "_")
res, ok := prefixToResourceType[in]
if !ok {
return ResourceInfo{Type: resource.Unknown}
}
return res
return prefixToResourceType[in]
}
// ResourcePrefixesFromType returns the known prefixes for a given type; if a
+1 -2
View File
@@ -20,10 +20,9 @@ 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)).Type)
assert.Equal(t, resource.Unknown, ResourceInfoFromPrefix(fmt.Sprintf("%sfoobar", prefix)))
}
}