testutil

package
v1.5.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 9, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package testutil provides test utilities for staging package.

Index

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) AddEntry

func (m *MockStore) AddEntry(service staging.Service, key staging.EntryKey, entry staging.Entry)

AddEntry is a helper to add entries directly for testing.

func (*MockStore) AddTag

func (m *MockStore) AddTag(service staging.Service, key staging.EntryKey, tag staging.TagEntry)

AddTag is a helper to add tag entries directly for testing.

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

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

func (m *MockStore) UnstageAll(_ context.Context, service staging.Service) error

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.

func (*MockStore) UnstageTag

func (m *MockStore) UnstageTag(_ context.Context, service staging.Service, key staging.EntryKey) error

UnstageTag removes the staged tag changes identified by key.

func (*MockStore) WriteState

func (m *MockStore) WriteState(_ context.Context, service staging.Service, state *staging.State) error

WriteState writes the entire state to storage. If service is empty, writes all services; otherwise writes only the specified service.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL