Documentation
¶
Index ¶
- type StateStoreMock
- func (mock *StateStoreMock) RecordUpdateCheck(checkedAt time.Time, latestVersion string) error
- func (mock *StateStoreMock) RecordUpdateCheckCalls() []struct{ ... }
- func (mock *StateStoreMock) SetLastSeenChangelog(version string) error
- func (mock *StateStoreMock) SetLastSeenChangelogCalls() []struct{ ... }
- func (mock *StateStoreMock) State() *state.State
- func (mock *StateStoreMock) StateCalls() []struct{}
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type StateStoreMock ¶
type StateStoreMock struct {
// RecordUpdateCheckFunc mocks the RecordUpdateCheck method.
RecordUpdateCheckFunc func(checkedAt time.Time, latestVersion string) error
// SetLastSeenChangelogFunc mocks the SetLastSeenChangelog method.
SetLastSeenChangelogFunc func(version string) error
// StateFunc mocks the State method.
StateFunc func() *state.State
// contains filtered or unexported fields
}
StateStoreMock is a mock implementation of state.StateStore.
func TestSomethingThatUsesStateStore(t *testing.T) {
// make and configure a mocked state.StateStore
mockedStateStore := &StateStoreMock{
RecordUpdateCheckFunc: func(checkedAt time.Time, latestVersion string) error {
panic("mock out the RecordUpdateCheck method")
},
SetLastSeenChangelogFunc: func(version string) error {
panic("mock out the SetLastSeenChangelog method")
},
StateFunc: func() *state.State {
panic("mock out the State method")
},
}
// use mockedStateStore in code that requires state.StateStore
// and then make assertions.
}
func NewBlankState ¶
func NewBlankState() *StateStoreMock
NewBlankState returns an in-memory *StateStoreMock seeded with a blank state snapshot. It is the default test double for consumers that don't care about specific state values.
func NewFromString ¶
func NewFromString(yaml string) *StateStoreMock
NewFromString returns an in-memory *StateStoreMock seeded from YAML. The YAML is parsed through the real schema, but state.NewFromString is the option-free in-memory seam (no WithStateDir), so the store discovers nothing on disk and touches no real XDG state dir: reads return the in-memory snapshot and writes are record-only. Legacy-key migrations do NOT run on the seam — that path is covered by intra-package New()+testenv tests. Panics on invalid YAML to match test-stub ergonomics.
func (*StateStoreMock) RecordUpdateCheck ¶
func (mock *StateStoreMock) RecordUpdateCheck(checkedAt time.Time, latestVersion string) error
RecordUpdateCheck calls RecordUpdateCheckFunc.
func (*StateStoreMock) RecordUpdateCheckCalls ¶
func (mock *StateStoreMock) RecordUpdateCheckCalls() []struct { CheckedAt time.Time LatestVersion string }
RecordUpdateCheckCalls gets all the calls that were made to RecordUpdateCheck. Check the length with:
len(mockedStateStore.RecordUpdateCheckCalls())
func (*StateStoreMock) SetLastSeenChangelog ¶
func (mock *StateStoreMock) SetLastSeenChangelog(version string) error
SetLastSeenChangelog calls SetLastSeenChangelogFunc.
func (*StateStoreMock) SetLastSeenChangelogCalls ¶
func (mock *StateStoreMock) SetLastSeenChangelogCalls() []struct { Version string }
SetLastSeenChangelogCalls gets all the calls that were made to SetLastSeenChangelog. Check the length with:
len(mockedStateStore.SetLastSeenChangelogCalls())
func (*StateStoreMock) State ¶
func (mock *StateStoreMock) State() *state.State
State calls StateFunc.
func (*StateStoreMock) StateCalls ¶
func (mock *StateStoreMock) StateCalls() []struct { }
StateCalls gets all the calls that were made to State. Check the length with:
len(mockedStateStore.StateCalls())