Documentation
¶
Overview ¶
Package keystoretest provides an in-memory keystore.Keystore for tests that need to exercise migration and error paths without touching a platform keyring (which isn't available or deterministic in unit tests). It is test-only infrastructure: nothing in the shipped binary imports it.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MockKeystore ¶
type MockKeystore struct {
// GetErr/SetErr/DeleteErr, when non-nil, are consulted before the operation;
// returning a non-nil error makes that operation fail. They receive the key
// name so a test can fail a specific key (or use a stateful closure to fail,
// say, only the verification read that follows a Set).
GetErr func(name string) error
SetErr func(name string) error
DeleteErr func(name string) error
// Tamper makes Set store a different value than it was given (simulating
// silent corruption), so the post-copy verification read mismatches.
Tamper map[string]string
// contains filtered or unexported fields
}
MockKeystore is an in-memory keystore with injectable failures. The zero value is not usable — call New.
func New ¶
func New(backend string) *MockKeystore
New returns an empty mock reporting the given backend name.
func (*MockKeystore) Backend ¶
func (m *MockKeystore) Backend() string
func (*MockKeystore) Delete ¶
func (m *MockKeystore) Delete(name string) error
func (*MockKeystore) Has ¶
func (m *MockKeystore) Has(name string) bool
Has reports whether an entry currently exists (test inspection helper).
func (*MockKeystore) Seed ¶
func (m *MockKeystore) Seed(name, secret string)
Seed pre-populates an entry, bypassing the error/tamper hooks.
func (*MockKeystore) Set ¶
func (m *MockKeystore) Set(name, secret string) error
Click to show internal directories.
Click to hide internal directories.