Documentation
¶
Overview ¶
Package testutil provides test utilities for staging package.
Index ¶
- type MockStore
- func (m *MockStore) AddEntry(service staging.Service, key staging.EntryKey, entry staging.Entry)
- func (m *MockStore) AddTag(service staging.Service, key staging.EntryKey, 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, key staging.EntryKey) (*staging.Entry, error)
- func (m *MockStore) GetTag(_ context.Context, service staging.Service, key staging.EntryKey) (*staging.TagEntry, error)
- func (m *MockStore) ListEntries(_ context.Context, service staging.Service) (map[staging.Service]map[staging.EntryKey]staging.Entry, error)
- func (m *MockStore) ListTags(_ context.Context, service staging.Service) (map[staging.Service]map[staging.EntryKey]staging.TagEntry, error)
- func (m *MockStore) StageEntry(_ context.Context, service staging.Service, key staging.EntryKey, ...) error
- func (m *MockStore) StageTag(_ context.Context, service staging.Service, key staging.EntryKey, ...) error
- func (m *MockStore) UnstageAll(_ context.Context, service staging.Service) error
- func (m *MockStore) UnstageEntry(_ context.Context, service staging.Service, key staging.EntryKey) error
- func (m *MockStore) UnstageTag(_ context.Context, service staging.Service, key staging.EntryKey) 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 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
// 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, key staging.EntryKey) (*staging.Entry, error)
GetEntry retrieves the staged entry identified by key.
func (*MockStore) GetTag ¶
func (m *MockStore) GetTag(_ context.Context, service staging.Service, key staging.EntryKey) (*staging.TagEntry, error)
GetTag retrieves the staged tag changes identified by key.
func (*MockStore) ListEntries ¶
func (m *MockStore) ListEntries(_ context.Context, service staging.Service) (map[staging.Service]map[staging.EntryKey]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[staging.EntryKey]staging.TagEntry, error)
ListTags returns all staged tag changes for a service.
func (*MockStore) StageEntry ¶
func (m *MockStore) StageEntry(_ context.Context, service staging.Service, key staging.EntryKey, entry staging.Entry) error
StageEntry adds or updates the staged entry identified by key.
func (*MockStore) StageTag ¶
func (m *MockStore) StageTag(_ context.Context, service staging.Service, key staging.EntryKey, tag staging.TagEntry) error
StageTag adds or updates the staged tag changes identified by key.
func (*MockStore) UnstageAll ¶
UnstageAll removes all staged changes for a service.
func (*MockStore) UnstageEntry ¶
func (m *MockStore) UnstageEntry(_ context.Context, service staging.Service, key staging.EntryKey) error
UnstageEntry removes the staged entry identified by key.