Files
threshold/globals/prefixes_test.go
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

28 lines
813 B
Go
Raw Normal View History

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1
package globals
import (
"fmt"
"testing"
2023-03-16 10:11:55 -04:00
"github.com/hashicorp/boundary/internal/types/resource"
"github.com/stretchr/testify/assert"
)
2023-11-02 16:03:47 -04:00
func TestResourceTypeFromPrefix(t *testing.T) {
// Test a random sampling
2023-03-16 10:11:55 -04:00
vals := map[string]resource.Type{
VaultCredentialLibraryPrefix: resource.CredentialLibrary,
OidcManagedGroupPrefix: resource.ManagedGroup,
StaticHostSetPrefix: resource.HostSet,
JsonCredentialPrefix: resource.Credential,
}
2023-03-16 10:11:55 -04:00
for prefix, typ := range vals {
2023-11-02 16:03:47 -04:00
assert.Equal(t, typ, ResourceTypeFromPrefix(prefix))
assert.Equal(t, typ, ResourceTypeFromPrefix(fmt.Sprintf("%s_foobar", prefix)))
assert.Equal(t, resource.Unknown, ResourceTypeFromPrefix(fmt.Sprintf("%sfoobar", prefix)))
}
}