Adds adjustment factor for assertions in auth enable tests (#22679)

* Adds adjustment factor for assertions in auth enable tests

* format comment
This commit is contained in:
Austin Gebauer
2023-08-30 15:51:49 -07:00
committed by GitHub
parent c31817abd0
commit 1acd0c6d24

View File

@@ -14,6 +14,12 @@ import (
"github.com/mitchellh/cli" "github.com/mitchellh/cli"
) )
// credentialBackendAdjustmentFactor allows for adjusting test assertions for
// credential backends. Add 1 to account for the "token" backend, which is visible
// when you walk the filesystem but is treated as special and excluded from the registry.
// Subtract 1 to account for "oidc" which is an alias of "jwt" and not a separate plugin.
var credentialBackendAdjustmentFactor = 1 - 1
func testAuthEnableCommand(tb testing.TB) (*cli.MockUi, *AuthEnableCommand) { func testAuthEnableCommand(tb testing.TB) (*cli.MockUi, *AuthEnableCommand) {
tb.Helper() tb.Helper()
@@ -205,10 +211,7 @@ func TestAuthEnableCommand_Run(t *testing.T) {
// of credential backends. // of credential backends.
backends = append(backends, "pcf") backends = append(backends, "pcf")
// Add 1 to account for the "token" backend, which is visible when you walk the filesystem but expected := len(builtinplugins.Registry.Keys(consts.PluginTypeCredential)) + credentialBackendAdjustmentFactor
// is treated as special and excluded from the registry.
// Subtract 1 to account for "oidc" which is an alias of "jwt" and not a separate plugin.
expected := len(builtinplugins.Registry.Keys(consts.PluginTypeCredential))
if len(backends) != expected { if len(backends) != expected {
t.Fatalf("expected %d credential backends, got %d", expected, len(backends)) t.Fatalf("expected %d credential backends, got %d", expected, len(backends))
} }