vault/command/server_util.go
Vault Automation 58e59e67b2
Backport license: update headers to IBM Corp. into release/1.21.x+ent (#10234) (#10252)
* license: update headers to IBM Corp.
* `make proto`
* update offset because source file changed
* update licenses in files that were not included in backport

Signed-off-by: Ryan Cragun <me@ryan.ec>
Co-authored-by: Ryan Cragun <me@ryan.ec>
2025-10-21 15:20:35 -06:00

54 lines
1.2 KiB
Go

// Copyright IBM Corp. 2016, 2025
// SPDX-License-Identifier: BUSL-1.1
package command
import (
"testing"
"github.com/hashicorp/cli"
"github.com/hashicorp/vault/sdk/physical"
physInmem "github.com/hashicorp/vault/sdk/physical/inmem"
)
func TestServerCommand(tb testing.TB) (*cli.MockUi, *ServerCommand) {
tb.Helper()
return testServerCommand(tb)
}
func (c *ServerCommand) StartedCh() chan struct{} {
return c.startedCh
}
func (c *ServerCommand) ReloadedCh() chan struct{} {
return c.reloadedCh
}
func (c *ServerCommand) LicenseReloadedCh() chan error {
return c.licenseReloadedCh
}
func testServerCommand(tb testing.TB) (*cli.MockUi, *ServerCommand) {
tb.Helper()
ui := cli.NewMockUi()
return ui, &ServerCommand{
BaseCommand: &BaseCommand{
UI: ui,
},
ShutdownCh: MakeShutdownCh(),
SighupCh: MakeSighupCh(),
SigUSR2Ch: MakeSigUSR2Ch(),
PhysicalBackends: map[string]physical.Factory{
"inmem": physInmem.NewInmem,
"inmem_ha": physInmem.NewInmemHA,
"inmem_transactional": physInmem.NewTransactionalInmem,
},
// These prevent us from random sleep guessing...
startedCh: make(chan struct{}, 5),
reloadedCh: make(chan struct{}, 5),
licenseReloadedCh: make(chan error, 1),
}
}