Documentation
¶
Overview ¶
Package testutil provides test utilities for staging package.
Index ¶
- type HintedMockStore
- func (m *HintedMockStore) UnstageAllWithHint(ctx context.Context, service staging.Service, hint string) error
- func (m *HintedMockStore) UnstageEntryWithHint(ctx context.Context, service staging.Service, name string, hint string) error
- func (m *HintedMockStore) UnstageTagWithHint(ctx context.Context, service staging.Service, name string, hint string) error
- type MockStore
- func (m *MockStore) AddEntry(service staging.Service, name string, entry staging.Entry)
- func (m *MockStore) AddTag(service staging.Service, name string, tag staging.TagEntry)
- func (m *MockStore) Drain(_ context.Context, service staging.Service, keep bool) (*staging.State, error)
- func (m *MockStore) GetEntry(_ context.Context, service staging.Service, name string) (*staging.Entry, error)
- func (m *MockStore) GetTag(_ context.Context, service staging.Service, name string) (*staging.TagEntry, error)
- func (m *MockStore) ListEntries(_ context.Context, service staging.Service) (map[staging.Service]map[string]staging.Entry, error)
- func (m *MockStore) ListTags(_ context.Context, service staging.Service) (map[staging.Service]map[string]staging.TagEntry, error)
- func (m *MockStore) Ping(_ context.Context) error
- func (m *MockStore) StageEntry(_ context.Context, service staging.Service, name string, entry staging.Entry) error
- func (m *MockStore) StageTag(_ context.Context, service staging.Service, name string, tag staging.TagEntry) error
- func (m *MockStore) Start(_ context.Context) error
- func (m *MockStore) UnstageAll(_ context.Context, service staging.Service) error
- func (m *MockStore) UnstageEntry(_ context.Context, service staging.Service, name string) error
- func (m *MockStore) UnstageTag(_ context.Context, service staging.Service, name string) error
- func (m *MockStore) WriteState(_ context.Context, service staging.Service, state *staging.State) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HintedMockStore ¶
type HintedMockStore struct {
*MockStore
UnstageEntryWithHintErr error
UnstageTagWithHintErr error
UnstageAllWithHintErr error
LastHint string // Records the last hint used
}
HintedMockStore extends MockStore with HintedUnstager support.
func NewHintedMockStore ¶
func NewHintedMockStore() *HintedMockStore
NewHintedMockStore creates a new HintedMockStore with initialized maps.
func (*HintedMockStore) UnstageAllWithHint ¶
func (m *HintedMockStore) UnstageAllWithHint(ctx context.Context, service staging.Service, hint string) error
UnstageAllWithHint removes all staged changes with an operation hint.
func (*HintedMockStore) UnstageEntryWithHint ¶
func (m *HintedMockStore) UnstageEntryWithHint(ctx context.Context, service staging.Service, name string, hint string) error
UnstageEntryWithHint removes a staged entry with an operation hint.
func (*HintedMockStore) UnstageTagWithHint ¶
func (m *HintedMockStore) UnstageTagWithHint(ctx context.Context, service staging.Service, name string, hint string) error
UnstageTagWithHint removes staged tag changes with an operation hint.
type MockStore ¶
type MockStore struct {
// Error injection for testing error paths
GetEntryErr error
GetTagErr error
StageEntryErr error
StageTagErr error
UnstageTagErr error
UnstageEntryErr error
UnstageAllErr error
ListEntriesErr error
ListTagsErr error
DrainErr error
WriteStateErr error
PingErr error
StartErr error
// DrainCallCount tracks the number of Drain calls
DrainCallCount int
// DrainErrOnCall specifies which call number (1-indexed) should return DrainErr
// If 0, DrainErr applies to all calls. If >0, DrainErr only applies to that call number.
DrainErrOnCall int
// contains filtered or unexported fields
}
MockStore implements store.ReadWriteOperator for testing. It stores state in memory and can be configured to return errors.
func NewMockStore ¶
func NewMockStore() *MockStore
NewMockStore creates a new MockStore with initialized maps.
func (*MockStore) Drain ¶
func (m *MockStore) Drain(_ context.Context, service staging.Service, keep bool) (*staging.State, error)
Drain retrieves the entire state from storage. If service is empty, returns all services; otherwise filters to the specified service. If keep is false, the source storage is cleared after reading.
func (*MockStore) GetEntry ¶
func (m *MockStore) GetEntry(_ context.Context, service staging.Service, name string) (*staging.Entry, error)
GetEntry retrieves a staged entry.
func (*MockStore) GetTag ¶
func (m *MockStore) GetTag(_ context.Context, service staging.Service, name string) (*staging.TagEntry, error)
GetTag retrieves staged tag changes.
func (*MockStore) ListEntries ¶
func (m *MockStore) ListEntries(_ context.Context, service staging.Service) (map[staging.Service]map[string]staging.Entry, error)
ListEntries returns all staged entries for a service.
func (*MockStore) ListTags ¶
func (m *MockStore) ListTags(_ context.Context, service staging.Service) (map[staging.Service]map[string]staging.TagEntry, error)
ListTags returns all staged tag changes for a service.
func (*MockStore) StageEntry ¶
func (m *MockStore) StageEntry(_ context.Context, service staging.Service, name string, entry staging.Entry) error
StageEntry adds or updates a staged entry change.
func (*MockStore) StageTag ¶
func (m *MockStore) StageTag(_ context.Context, service staging.Service, name string, tag staging.TagEntry) error
StageTag adds or updates staged tag changes.
func (*MockStore) Start ¶ added in v0.7.2
Start ensures the agent daemon is running, starting it if necessary.
func (*MockStore) UnstageAll ¶
UnstageAll removes all staged changes for a service.
func (*MockStore) UnstageEntry ¶
UnstageEntry removes a staged entry change.
func (*MockStore) UnstageTag ¶
UnstageTag removes staged tag changes.