Files
threshold/globals/prefixes_test.go
T
Jeff Mitchell a9e372930d Revert 0bf60996c5 (#3990)
Post-merge some issues were discovered with the ways typing is used for
proto reflection. This will be reworked without moving the subtypes
around.
2023-11-02 16:03:47 -04:00

29 lines
813 B
Go

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1
package globals
import (
"fmt"
"testing"
"github.com/hashicorp/boundary/internal/types/resource"
"github.com/stretchr/testify/assert"
)
func TestResourceTypeFromPrefix(t *testing.T) {
// Test a random sampling
vals := map[string]resource.Type{
VaultCredentialLibraryPrefix: resource.CredentialLibrary,
OidcManagedGroupPrefix: resource.ManagedGroup,
StaticHostSetPrefix: resource.HostSet,
JsonCredentialPrefix: resource.Credential,
}
for prefix, typ := range vals {
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)))
}
}