Documentation
¶
Overview ¶
Package fakes provides in-memory implementations of every db.*Store interface. They satisfy the same contracts as the production stores but hold state in maps; pair with testutil/testserver for handler tests, or inject directly into services that need stores without Postgres.
Index ¶
- type ConfigStore
- func (s *ConfigStore) Get(_ context.Context, key string) (json.RawMessage, error)
- func (s *ConfigStore) GetAll(_ context.Context) (map[string]json.RawMessage, error)
- func (s *ConfigStore) GetAppConfig(_ context.Context) (config.AppConfig, error)
- func (s *ConfigStore) Set(_ context.Context, key string, value json.RawMessage) error
- func (s *ConfigStore) UpdateAppConfig(_ context.Context, c config.AppConfig) error
- type ConnectorStore
- func (s *ConnectorStore) All() []db.Connector
- func (s *ConnectorStore) Delete(_ context.Context, id uuid.UUID) error
- func (s *ConnectorStore) Get(_ context.Context, id uuid.UUID) (*db.Connector, error)
- func (s *ConnectorStore) GetByName(_ context.Context, name string) (*db.Connector, error)
- func (s *ConnectorStore) GetDefault(_ context.Context, connectorType string) (*db.Connector, error)
- func (s *ConnectorStore) List(_ context.Context) ([]db.Connector, error)
- func (s *ConnectorStore) Save(_ context.Context, name, connectorType, description string, ...) (*db.Connector, error)
- func (s *ConnectorStore) Update(_ context.Context, id uuid.UUID, name, description string, ...) error
- type PackStore
- func (s *PackStore) Delete(_ context.Context, name string) error
- func (s *PackStore) Get(_ context.Context, name string) (*db.Pack, error)
- func (s *PackStore) List(_ context.Context) ([]db.Pack, error)
- func (s *PackStore) UpdateParameters(_ context.Context, name string, parameters map[string]any) error
- func (s *PackStore) Upsert(_ context.Context, pack *db.Pack, installedBy string) error
- type RunStore
- func (s *RunStore) AddScenarioResult(_ context.Context, runID uuid.UUID, result *db.ScenarioResult) error
- func (s *RunStore) All() []db.Run
- func (s *RunStore) CompleteRun(_ context.Context, id uuid.UUID, endTime *time.Time) error
- func (s *RunStore) CompleteScenarioResult(_ context.Context, id uuid.UUID, result *db.ScenarioResult) error
- func (s *RunStore) Create(_ context.Context, run *db.Run) error
- func (s *RunStore) CreateScenarioStatus(_ context.Context, runID uuid.UUID, name string) (uuid.UUID, error)
- func (s *RunStore) Delete(_ context.Context, id uuid.UUID) error
- func (s *RunStore) Get(_ context.Context, id uuid.UUID) (*db.Run, error)
- func (s *RunStore) GetLatestExpectationResults(_ context.Context) ([]db.LatestExpectationResult, error)
- func (s *RunStore) GetScenarioResult(_ context.Context, id uuid.UUID) (*db.ScenarioResult, error)
- func (s *RunStore) GetScenarioResults(_ context.Context, runID uuid.UUID) ([]db.ScenarioResult, error)
- func (s *RunStore) IncrementRunCounters(_ context.Context, id uuid.UUID, successDelta, failDelta int) error
- func (s *RunStore) List(_ context.Context, filters db.ListRunsFilters, limit, offset int) (db.RunPage, error)
- func (s *RunStore) ListExpired(_ context.Context, cutoff time.Time) ([]uuid.UUID, error)
- func (s *RunStore) Update(_ context.Context, id uuid.UUID, status string, total, succeeded, failed int, ...) error
- func (s *RunStore) UpdateScenarioExpectations(_ context.Context, id uuid.UUID, expectationsJSON []byte) error
- func (s *RunStore) UpdateScenarioIdentity(_ context.Context, id uuid.UUID, ...) error
- func (s *RunStore) UpdateScenarioPhase(_ context.Context, id uuid.UUID, phase string) error
- type ScenarioStore
- func (s *ScenarioStore) Delete(_ context.Context, id uuid.UUID) error
- func (s *ScenarioStore) Get(_ context.Context, id uuid.UUID) (*db.Assessment, error)
- func (s *ScenarioStore) GetByName(_ context.Context, name string) (*db.Assessment, error)
- func (s *ScenarioStore) List(_ context.Context, filters db.ListAssessmentsFilters, limit, offset int) (db.AssessmentPage, error)
- func (s *ScenarioStore) ListAll(_ context.Context) ([]db.Assessment, error)
- func (s *ScenarioStore) Save(_ context.Context, name, scenarioType, yaml, createdBy string) (*db.Assessment, error)
- func (s *ScenarioStore) SetUpdatedAt(id uuid.UUID, t time.Time)
- func (s *ScenarioStore) Update(_ context.Context, id uuid.UUID, name, scenarioType, yaml, updatedBy string) error
- type ScheduleStore
- func (s *ScheduleStore) Create(_ context.Context, assessmentID uuid.UUID, cronExpr string, enabled bool, ...) (*db.Schedule, error)
- func (s *ScheduleStore) Delete(_ context.Context, id uuid.UUID) error
- func (s *ScheduleStore) Get(_ context.Context, id uuid.UUID) (*db.Schedule, error)
- func (s *ScheduleStore) GetByAssessmentID(_ context.Context, assessmentID uuid.UUID) (*db.Schedule, error)
- func (s *ScheduleStore) List(_ context.Context) ([]db.Schedule, error)
- func (s *ScheduleStore) ListEnabled(ctx context.Context) ([]db.Schedule, error)
- func (s *ScheduleStore) Update(_ context.Context, id uuid.UUID, cronExpr string, enabled bool, ...) error
- func (s *ScheduleStore) UpdateLastRun(_ context.Context, id uuid.UUID, lastRunAt time.Time) error
- type SecretStore
- func (s *SecretStore) Delete(_ context.Context, id uuid.UUID) error
- func (s *SecretStore) Get(_ context.Context, id uuid.UUID) (*db.SecretGroup, error)
- func (s *SecretStore) List(_ context.Context) ([]db.SecretGroup, error)
- func (s *SecretStore) Save(_ context.Context, name, description string, entries json.RawMessage, ...) (*db.SecretGroup, error)
- func (s *SecretStore) Update(_ context.Context, id uuid.UUID, name, description string, ...) error
- type SessionStore
- func (s *SessionStore) Create(_ context.Context, email, name, picture string, ttl time.Duration) (string, error)
- func (s *SessionStore) Delete(_ context.Context, sessionID string) error
- func (s *SessionStore) DeleteExpired(_ context.Context) error
- func (s *SessionStore) Get(_ context.Context, sessionID string) (*db.AuthSession, error)
- type Stores
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConfigStore ¶
type ConfigStore struct {
// contains filtered or unexported fields
}
func (*ConfigStore) Get ¶
func (s *ConfigStore) Get(_ context.Context, key string) (json.RawMessage, error)
func (*ConfigStore) GetAll ¶
func (s *ConfigStore) GetAll(_ context.Context) (map[string]json.RawMessage, error)
func (*ConfigStore) GetAppConfig ¶
GetAppConfig assembles the typed AppConfig from the stored JSON keys. When a key is missing or malformed, falls back to that field's default — matches the production store's tolerant parsing.
func (*ConfigStore) Set ¶
func (s *ConfigStore) Set(_ context.Context, key string, value json.RawMessage) error
func (*ConfigStore) UpdateAppConfig ¶
type ConnectorStore ¶
type ConnectorStore struct {
// contains filtered or unexported fields
}
func (*ConnectorStore) All ¶
func (s *ConnectorStore) All() []db.Connector
All returns a snapshot of all connectors (test-only convenience).
func (*ConnectorStore) GetDefault ¶
type PackStore ¶
type PackStore struct {
// contains filtered or unexported fields
}
func (*PackStore) UpdateParameters ¶
type RunStore ¶
type RunStore struct {
// contains filtered or unexported fields
}
func (*RunStore) AddScenarioResult ¶
func (*RunStore) CompleteRun ¶
func (*RunStore) CompleteScenarioResult ¶
func (*RunStore) CreateScenarioStatus ¶
func (*RunStore) GetLatestExpectationResults ¶ added in v0.4.0
func (*RunStore) GetScenarioResult ¶
func (*RunStore) GetScenarioResults ¶
func (*RunStore) IncrementRunCounters ¶
func (*RunStore) ListExpired ¶ added in v0.2.0
func (*RunStore) UpdateScenarioExpectations ¶ added in v0.4.0
func (*RunStore) UpdateScenarioIdentity ¶ added in v0.3.0
type ScenarioStore ¶
type ScenarioStore struct {
// contains filtered or unexported fields
}
func (*ScenarioStore) Get ¶
func (s *ScenarioStore) Get(_ context.Context, id uuid.UUID) (*db.Assessment, error)
func (*ScenarioStore) GetByName ¶ added in v0.4.0
func (s *ScenarioStore) GetByName(_ context.Context, name string) (*db.Assessment, error)
func (*ScenarioStore) List ¶
func (s *ScenarioStore) List(_ context.Context, filters db.ListAssessmentsFilters, limit, offset int) (db.AssessmentPage, error)
func (*ScenarioStore) ListAll ¶
func (s *ScenarioStore) ListAll(_ context.Context) ([]db.Assessment, error)
func (*ScenarioStore) Save ¶
func (s *ScenarioStore) Save(_ context.Context, name, scenarioType, yaml, createdBy string) (*db.Assessment, error)
func (*ScenarioStore) SetUpdatedAt ¶
func (s *ScenarioStore) SetUpdatedAt(id uuid.UUID, t time.Time)
SetUpdatedAt backdates a scenario's UpdatedAt for tests exercising the `since` filter; no-op if the scenario is unknown.
type ScheduleStore ¶
type ScheduleStore struct {
// contains filtered or unexported fields
}
func (*ScheduleStore) GetByAssessmentID ¶ added in v0.4.0
func (*ScheduleStore) ListEnabled ¶
func (*ScheduleStore) UpdateLastRun ¶
type SecretStore ¶
type SecretStore struct {
// contains filtered or unexported fields
}
func (*SecretStore) Get ¶
func (s *SecretStore) Get(_ context.Context, id uuid.UUID) (*db.SecretGroup, error)
func (*SecretStore) List ¶
func (s *SecretStore) List(_ context.Context) ([]db.SecretGroup, error)
func (*SecretStore) Save ¶
func (s *SecretStore) Save(_ context.Context, name, description string, entries json.RawMessage, createdBy string) (*db.SecretGroup, error)
type SessionStore ¶
type SessionStore struct {
// contains filtered or unexported fields
}
func (*SessionStore) Delete ¶
func (s *SessionStore) Delete(_ context.Context, sessionID string) error
func (*SessionStore) DeleteExpired ¶
func (s *SessionStore) DeleteExpired(_ context.Context) error
func (*SessionStore) Get ¶
func (s *SessionStore) Get(_ context.Context, sessionID string) (*db.AuthSession, error)
type Stores ¶
type Stores struct {
Run *RunStore
Scenario *ScenarioStore
Pack *PackStore
Secret *SecretStore
Connector *ConnectorStore
Config *ConfigStore
Schedule *ScheduleStore
Session *SessionStore
}
Stores bundles every fake store. Use New() to construct a wired-up bundle.