vault/command/commands_full_test.go

46 lines
1.5 KiB
Go

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1
//go:build !enterprise && !minimal
package command
import (
"maps"
"testing"
"github.com/stretchr/testify/require"
)
// Test_extendAddonCommands tests extendAddonCommands() extends physical and logical backends with
// those generated by newFullAddonCommands()
func Test_extendAddonCommands(t *testing.T) {
expMinPhysicalBackends := maps.Clone(physicalBackends)
expMinLoginHandlers := maps.Clone(loginHandlers)
expAddonPhysicalBackends, expAddonLoginHandlers := newFullAddonCommands()
extendAddonCommands()
require.Equal(t, len(expMinPhysicalBackends)+len(expAddonPhysicalBackends), len(physicalBackends),
"extended total physical backends mismatch total of minimal and full addon physical backends")
require.Equal(t, len(expMinLoginHandlers)+len(expAddonLoginHandlers), len(loginHandlers),
"extended total login handlers mismatch total of minimal and full addon login handlers")
for k := range expMinPhysicalBackends {
require.Contains(t, physicalBackends, k, "expected to contain minimal physical backend")
}
for k := range expAddonPhysicalBackends {
require.Contains(t, physicalBackends, k, "expected to contain full addon physical backend")
}
for k := range expMinLoginHandlers {
require.Contains(t, loginHandlers, k, "expected to contain minimal login handler")
}
for k := range expAddonLoginHandlers {
require.Contains(t, loginHandlers, k, "expected to contain full addon login handler")
}
}