mock

package
v0.2.0-alpha.4 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package mock provides test-only in-memory implementations for unit tests. It must not be imported by production code.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DenyQuotaTeamStore

type DenyQuotaTeamStore struct {
	Team *coreteam.Team
}

DenyQuotaTeamStore is used by quota 429 tests to supply a team with tier.

func (*DenyQuotaTeamStore) AddTeamMember

func (d *DenyQuotaTeamStore) AddTeamMember(_ context.Context, _, _, _ string) (*coreteam.Member, error)

func (*DenyQuotaTeamStore) CountTeamMembers

func (d *DenyQuotaTeamStore) CountTeamMembers(_ context.Context, _ []string) (map[string]int, error)

func (*DenyQuotaTeamStore) CreateTeam

func (d *DenyQuotaTeamStore) CreateTeam(_ context.Context, _, _, _ string) (*coreteam.Team, error)

func (*DenyQuotaTeamStore) GetPersonalTeamByUser

func (d *DenyQuotaTeamStore) GetPersonalTeamByUser(_ context.Context, _ string) (*coreteam.Team, error)

func (*DenyQuotaTeamStore) GetTeam

func (*DenyQuotaTeamStore) ListAllTeams

func (d *DenyQuotaTeamStore) ListAllTeams(_ context.Context, _ string, _, _ int) ([]coreteam.Team, int, error)

func (*DenyQuotaTeamStore) ListTeamMembers

func (d *DenyQuotaTeamStore) ListTeamMembers(_ context.Context, _ string) ([]coreteam.Member, error)

func (*DenyQuotaTeamStore) ListTeamsByUser

func (d *DenyQuotaTeamStore) ListTeamsByUser(_ context.Context, _ string) ([]coreteam.Team, error)

func (*DenyQuotaTeamStore) RemoveTeamMember

func (d *DenyQuotaTeamStore) RemoveTeamMember(_ context.Context, _, _ string) error

func (*DenyQuotaTeamStore) SetTeamPluginCuration

func (d *DenyQuotaTeamStore) SetTeamPluginCuration(_ context.Context, _ string, _ coreplugin.Curation) error

type DenyQuotaTierStore

type DenyQuotaTierStore struct {
	Tier *corequota.Tier
}

DenyQuotaTierStore is used by quota 429 tests.

func (*DenyQuotaTierStore) GetQuotaTier

func (d *DenyQuotaTierStore) GetQuotaTier(_ context.Context, _ string) (*corequota.Tier, error)

type DenyQuotaUsageReader

type DenyQuotaUsageReader struct {
	RunCount    int
	TotalTokens int
}

DenyQuotaUsageReader is used by quota 429 tests.

func (*DenyQuotaUsageReader) TeamUsageInWindow

func (d *DenyQuotaUsageReader) TeamUsageInWindow(_ context.Context, _ string, _, _ time.Time) (int, int, error)

type MockAgentStore

type MockAgentStore struct {
	Agents    []agentdef.Agent
	Revisions []agentdef.Revision
}

MockAgentStore is an in-memory AgentStore for tests. It records revisions the way the database store does, so a test can assert on history.

func (*MockAgentStore) CreateAgentInTeam

func (m *MockAgentStore) CreateAgentInTeam(_ context.Context, in agentdef.CreateInput) (*agentdef.Agent, error)

func (*MockAgentStore) DeleteAgent

func (m *MockAgentStore) DeleteAgent(_ context.Context, agentID, userID string) error

func (*MockAgentStore) DeleteAgentInTeam

func (m *MockAgentStore) DeleteAgentInTeam(_ context.Context, agentID, teamID string) error

func (*MockAgentStore) GetAgent

func (m *MockAgentStore) GetAgent(_ context.Context, agentID string) (*agentdef.Agent, error)

func (*MockAgentStore) GetAgentIncludingDeleted

func (m *MockAgentStore) GetAgentIncludingDeleted(_ context.Context, agentID string) (*agentdef.Agent, error)

func (*MockAgentStore) GetAgentRevision

func (m *MockAgentStore) GetAgentRevision(_ context.Context, agentID string, revision int) (*agentdef.Revision, error)

func (*MockAgentStore) ListAgentRevisions

func (m *MockAgentStore) ListAgentRevisions(_ context.Context, agentID string, limit, offset int) ([]agentdef.Revision, int, error)

func (*MockAgentStore) ListAgentsByTeam

func (m *MockAgentStore) ListAgentsByTeam(_ context.Context, teamID string) ([]agentdef.Agent, error)

func (*MockAgentStore) ListAgentsByUser

func (m *MockAgentStore) ListAgentsByUser(_ context.Context, userID string) ([]agentdef.Agent, error)

func (*MockAgentStore) UpdateAgentInTeam

func (m *MockAgentStore) UpdateAgentInTeam(_ context.Context, in agentdef.UpdateInput) (*agentdef.Agent, error)

type MockArtifactStorage

type MockArtifactStorage struct {

	// PutErr, when set, fails every write.
	PutErr error
	// contains filtered or unexported fields
}

MockArtifactStorage is an in-memory artifact.ContentStore for tests.

func NewMockArtifactStorage

func NewMockArtifactStorage() *MockArtifactStorage

NewMockArtifactStorage returns a MockArtifactStorage ready for use.

func (*MockArtifactStorage) ObjectCount

func (m *MockArtifactStorage) ObjectCount() int

ObjectCount reports how many objects are stored, so a test can prove that a failed create left nothing behind.

func (*MockArtifactStorage) OpenArtifact

func (*MockArtifactStorage) PutArtifact

func (m *MockArtifactStorage) PutArtifact(_ context.Context, ref coreartifact.Ref, r io.Reader) (string, error)

func (*MockArtifactStorage) RemoveArtifact

func (m *MockArtifactStorage) RemoveArtifact(_ context.Context, ref coreartifact.Ref) error

type MockArtifactStore

type MockArtifactStore struct {

	// CreateErr, when set, fails every create — the case where content is
	// already durable and the record is not.
	CreateErr error
	// contains filtered or unexported fields
}

MockArtifactStore is an in-memory coreartifact.Store for tests.

func (*MockArtifactStore) Count

func (m *MockArtifactStore) Count() int

Count reports how many records exist, tombstoned ones included. Tests use it to prove that a failed create left none.

func (*MockArtifactStore) CreateArtifact

func (*MockArtifactStore) GetArtifact

func (m *MockArtifactStore) GetArtifact(_ context.Context, artifactID string) (*coreartifact.Artifact, error)

func (*MockArtifactStore) ListArtifactsBySource

func (m *MockArtifactStore) ListArtifactsBySource(_ context.Context, sourceIDs []string) (map[string][]coreartifact.Artifact, error)

func (*MockArtifactStore) ListArtifactsByTeam

func (m *MockArtifactStore) ListArtifactsByTeam(_ context.Context, teamID string, limit, offset int) ([]coreartifact.Artifact, int, error)

func (*MockArtifactStore) SoftDeleteArtifact

func (m *MockArtifactStore) SoftDeleteArtifact(_ context.Context, artifactID string, deletedAt time.Time) (bool, error)

type MockAuditStore

type MockAuditStore struct {
	Events []coreaudit.Event
	// Err, when set, is returned by RecordAuditEvent so a caller's behaviour
	// on a failed write can be exercised.
	Err error
}

MockAuditStore is an in-memory coreaudit.Store for tests.

func (*MockAuditStore) ExportAuditEvents

func (m *MockAuditStore) ExportAuditEvents(_ context.Context, filter coreaudit.Filter, after coreaudit.Cursor, limit int) ([]coreaudit.Event, error)

ExportAuditEvents walks every team's events newest-first from after.

func (*MockAuditStore) ExportTeamAuditEvents

func (m *MockAuditStore) ExportTeamAuditEvents(_ context.Context, teamID string, after coreaudit.Cursor, limit int) ([]coreaudit.Event, error)

ExportTeamAuditEvents walks a team's events newest-first from after.

func (*MockAuditStore) ListAuditEvents

func (m *MockAuditStore) ListAuditEvents(_ context.Context, teamID string, limit, offset int) ([]coreaudit.Event, int, error)

func (*MockAuditStore) OldestAuditEventAt

func (m *MockAuditStore) OldestAuditEventAt(_ context.Context) (time.Time, error)

OldestAuditEventAt returns the earliest recorded timestamp, or zero.

func (*MockAuditStore) PruneAuditEvents

func (m *MockAuditStore) PruneAuditEvents(_ context.Context, before time.Time, limit int) (int64, error)

PruneAuditEvents removes events older than the cutoff, at most limit of them.

func (*MockAuditStore) RecordAuditEvent

func (m *MockAuditStore) RecordAuditEvent(_ context.Context, in coreaudit.Event) error

func (*MockAuditStore) SearchAuditEvents

func (m *MockAuditStore) SearchAuditEvents(_ context.Context, filter coreaudit.Filter, limit, offset int) ([]coreaudit.Event, int, error)

type MockConversationMessageStore

type MockConversationMessageStore struct {
	Messages []coreconv.Message
	// contains filtered or unexported fields
}

MockConversationMessageStore is an in-memory ConversationMessageStore.

Every appended message gets its own handle. That matters more than it looks: a run records the message that asked for it, and a store handing out one shared ID would let that assertion pass on any message at all.

func (*MockConversationMessageStore) AppendMessage

func (*MockConversationMessageStore) GetMessage

func (m *MockConversationMessageStore) GetMessage(_ context.Context, messageID string) (*coreconv.Message, error)

func (*MockConversationMessageStore) ListMessages

func (m *MockConversationMessageStore) ListMessages(_ context.Context, conversationID string) ([]coreconv.Message, error)

type MockConversationStore

type MockConversationStore struct {
	Conversations []coreconv.Conversation
}

MockConversationStore is an in-memory ConversationStore for tests.

func (*MockConversationStore) CreateConversation

func (m *MockConversationStore) CreateConversation(_ context.Context, userID, channel, createdBy string) (*coreconv.Conversation, error)

func (*MockConversationStore) CreateConversationInTeam

func (m *MockConversationStore) CreateConversationInTeam(_ context.Context, teamID, userID, channel, createdBy string) (*coreconv.Conversation, error)

func (*MockConversationStore) GetConversation

func (m *MockConversationStore) GetConversation(_ context.Context, conversationID string) (*coreconv.Conversation, error)

func (*MockConversationStore) ListConversationsByTeam

func (m *MockConversationStore) ListConversationsByTeam(_ context.Context, teamID string, limit, offset int) ([]coreconv.Conversation, int, error)

func (*MockConversationStore) ListConversationsByUser

func (m *MockConversationStore) ListConversationsByUser(_ context.Context, userID string, limit, offset int) ([]coreconv.Conversation, int, error)

func (*MockConversationStore) UpdateConversationTitle

func (m *MockConversationStore) UpdateConversationTitle(_ context.Context, conversationID, title string) error

type MockIssueCommentStore

type MockIssueCommentStore struct {
	Comments []coreissue.Comment
	// CreateErr, when set, is returned by CreateIssueComment. It exists so a
	// test can prove a failed comment write does not fail the run that
	// triggered it.
	CreateErr error
}

MockIssueCommentStore is an in-memory IssueCommentStore for tests.

func (*MockIssueCommentStore) CountIssueComments

func (m *MockIssueCommentStore) CountIssueComments(_ context.Context, issueIDs []string) (map[string]int, error)

func (*MockIssueCommentStore) CreateIssueComment

func (*MockIssueCommentStore) DeleteIssueComment

func (m *MockIssueCommentStore) DeleteIssueComment(_ context.Context, commentID string) error

func (*MockIssueCommentStore) GetIssueComment

func (m *MockIssueCommentStore) GetIssueComment(_ context.Context, commentID string) (*coreissue.Comment, error)

func (*MockIssueCommentStore) ListIssueComments

func (m *MockIssueCommentStore) ListIssueComments(_ context.Context, issueID string, limit, offset int) ([]coreissue.Comment, int, error)

func (*MockIssueCommentStore) UpdateIssueComment

func (m *MockIssueCommentStore) UpdateIssueComment(_ context.Context, commentID, body string) (*coreissue.Comment, error)

type MockIssueStore

type MockIssueStore struct {
	Issues []coreissue.Issue
}

MockIssueStore is an in-memory IssueStore for tests.

func (*MockIssueStore) ChildStatsForIssues

func (m *MockIssueStore) ChildStatsForIssues(_ context.Context, issueIDs []string) (map[string]coreissue.ChildStats, error)

func (*MockIssueStore) CreateIssue

func (m *MockIssueStore) CreateIssue(_ context.Context, userID string, in coreissue.CreateInput) (*coreissue.Issue, error)

func (*MockIssueStore) CreateIssueInTeam

func (m *MockIssueStore) CreateIssueInTeam(_ context.Context, teamID, createdBy string, in coreissue.CreateInput) (*coreissue.Issue, error)

func (*MockIssueStore) GetIssue

func (m *MockIssueStore) GetIssue(_ context.Context, issueID string) (*coreissue.Issue, error)

func (*MockIssueStore) ListIssueChildren

func (m *MockIssueStore) ListIssueChildren(_ context.Context, parentIssueID string) ([]coreissue.Issue, error)

func (*MockIssueStore) ListIssuesByTeam

func (m *MockIssueStore) ListIssuesByTeam(_ context.Context, teamID string, filter coreissue.ListFilter, limit, offset int) ([]coreissue.Issue, int, error)

func (*MockIssueStore) ListIssuesByUser

func (m *MockIssueStore) ListIssuesByUser(_ context.Context, userID string, limit, offset int) ([]coreissue.Issue, int, error)

func (*MockIssueStore) UpdateIssue

func (m *MockIssueStore) UpdateIssue(_ context.Context, issueID, userID string, in coreissue.UpdateInput) (*coreissue.Issue, error)

func (*MockIssueStore) UpdateIssueInTeam

func (m *MockIssueStore) UpdateIssueInTeam(_ context.Context, issueID, teamID string, in coreissue.UpdateInput) (*coreissue.Issue, error)

type MockLLMModelStore

type MockLLMModelStore struct {
	Models      []coregw.Model
	Credentials map[string]string
	Err         error
	// contains filtered or unexported fields
}

MockLLMModelStore is an in-memory LLMModelStore for tests.

Credentials are kept in a separate map, mirroring the real store: reading a model and reading its key are different operations, and a mock that stapled the key onto the record would let a handler test pass while the endpoint serialized it.

func (*MockLLMModelStore) CreateLLMModel

func (*MockLLMModelStore) GetLLMModel

func (m *MockLLMModelStore) GetLLMModel(_ context.Context, llmModelID string) (*coregw.Model, error)

func (*MockLLMModelStore) GetLLMModelByName

func (m *MockLLMModelStore) GetLLMModelByName(_ context.Context, name string) (*coregw.Model, error)

func (*MockLLMModelStore) LLMModelCredential

func (m *MockLLMModelStore) LLMModelCredential(_ context.Context, llmModelID string) (string, error)

func (*MockLLMModelStore) ListLLMModels

func (m *MockLLMModelStore) ListLLMModels(_ context.Context) ([]coregw.Model, error)

func (*MockLLMModelStore) SetLLMModelEnabled

func (m *MockLLMModelStore) SetLLMModelEnabled(_ context.Context, llmModelID string, enabled bool) error

type MockLoginCode

type MockLoginCode struct {
	UserID    string
	ExpiresAt time.Time
	Used      bool
}

MockLoginCode is one issued code in MockLoginCodeStore.

type MockLoginCodeStore

type MockLoginCodeStore struct {
	Codes      map[string]*MockLoginCode
	ConsumeErr error
	Issued     []string
}

MockLoginCodeStore is an in-memory LoginCodeStore for tests. Seed Codes with the plaintext a test will submit; ConsumeErr forces a store failure.

func (*MockLoginCodeStore) ConsumeLoginCode

func (m *MockLoginCodeStore) ConsumeLoginCode(_ context.Context, plaintext, userID string, now time.Time) (bool, error)

ConsumeLoginCode mirrors the real store: unknown, spent, expired, and somebody else's codes are all reported the same way, as not redeemed rather than as an error, and only a match is marked used.

func (*MockLoginCodeStore) CreateLoginCode

func (m *MockLoginCodeStore) CreateLoginCode(_ context.Context, userID string, ttl time.Duration) (string, time.Time, error)

type MockPasswordStore

type MockPasswordStore struct {
	Hashes  map[string]string
	ReadErr error
	SetErr  error
}

MockPasswordStore is an in-memory PasswordStore for tests. Seed Hashes with the encoded hash a test expects to verify against.

func (*MockPasswordStore) PasswordHash

func (m *MockPasswordStore) PasswordHash(_ context.Context, userID string) (string, error)

func (*MockPasswordStore) SetPassword

func (m *MockPasswordStore) SetPassword(_ context.Context, userID, encodedHash string, _ time.Time) error

type MockPersistStorage

type MockPersistStorage struct {
	// RunGlobal is keyed by createdBy/conversationID/taskID/taskRunID/relPath.
	RunGlobal map[string][]byte
	// RunArtifacts uses the same key shape.
	RunArtifacts map[string][]byte
}

MockPersistStorage is an in-memory blob.PersistStorage for tests. Only the run-global half is backed by a map; the home-file methods satisfy the interface and are inert, because the handlers that need this mock read run state, not team files.

func NewMockPersistStorage

func NewMockPersistStorage() *MockPersistStorage

NewMockPersistStorage returns a MockPersistStorage ready for use.

func (*MockPersistStorage) Get

func (m *MockPersistStorage) Get(_ context.Context, _ string, _ string) ([]byte, error)

func (*MockPersistStorage) GetRunArtifacts

func (m *MockPersistStorage) GetRunArtifacts(_ context.Context, ref blob.RunObjectRef) ([]byte, error)

func (*MockPersistStorage) GetRunGlobal

func (m *MockPersistStorage) GetRunGlobal(_ context.Context, ref blob.RunObjectRef) ([]byte, error)

func (*MockPersistStorage) ListFiles

func (m *MockPersistStorage) ListFiles(_ context.Context, _ string) ([]string, error)

func (*MockPersistStorage) MaterializeToDir

func (m *MockPersistStorage) MaterializeToDir(_ context.Context, _ string, _ string) error

func (*MockPersistStorage) Put

func (*MockPersistStorage) PutRunArtifacts

func (m *MockPersistStorage) PutRunArtifacts(_ context.Context, ref blob.RunObjectRef, r io.Reader) error

func (*MockPersistStorage) PutRunGlobal

func (m *MockPersistStorage) PutRunGlobal(_ context.Context, ref blob.RunObjectRef, r io.Reader) error

type MockPluginActivationStore

type MockPluginActivationStore struct {
	// contains filtered or unexported fields
}

MockPluginActivationStore is an in-memory team activation store for tests.

func NewMockPluginActivationStore

func NewMockPluginActivationStore() *MockPluginActivationStore

func (*MockPluginActivationStore) ActivatePlugin

func (*MockPluginActivationStore) GetPluginActivation

func (m *MockPluginActivationStore) GetPluginActivation(_ context.Context, teamID, pluginName string) (*coreplugin.Activation, error)

func (*MockPluginActivationStore) ListPluginActivations

func (m *MockPluginActivationStore) ListPluginActivations(_ context.Context, teamID string) ([]coreplugin.Activation, error)

func (*MockPluginActivationStore) MovePluginActivationPin

func (*MockPluginActivationStore) SetPluginActivationEnabled

func (m *MockPluginActivationStore) SetPluginActivationEnabled(_ context.Context, teamID, pluginName string, enabled bool, actorID string) (*coreplugin.Activation, error)

type MockPluginPackageStorage

type MockPluginPackageStorage struct{ Objects map[string][]byte }

MockPluginPackageStorage is an in-memory plugin.PackageStore.

func NewMockPluginPackageStorage

func NewMockPluginPackageStorage() *MockPluginPackageStorage

NewMockPluginPackageStorage returns empty storage.

func (*MockPluginPackageStorage) Exists

func (*MockPluginPackageStorage) Open

func (*MockPluginPackageStorage) PackageKey

func (f *MockPluginPackageStorage) PackageKey(prefix, pluginName, digest string) (string, error)

PackageKey delegates to the real layout, so a key a test stores under is the key production would have used.

func (*MockPluginPackageStorage) Put

type MockPluginStore

type MockPluginStore struct {
	// contains filtered or unexported fields
}

MockPluginStore is an in-memory Marketplace catalog for tests.

func NewMockPluginStore

func NewMockPluginStore() *MockPluginStore

func (*MockPluginStore) CreatePlugin

func (*MockPluginStore) CreatePluginRelease

func (*MockPluginStore) GetPlugin

func (f *MockPluginStore) GetPlugin(_ context.Context, name string) (*coreplugin.Plugin, error)

func (*MockPluginStore) GetPluginRelease

func (f *MockPluginStore) GetPluginRelease(_ context.Context, name, version string) (*coreplugin.Release, error)

func (*MockPluginStore) ListPluginReleases

func (f *MockPluginStore) ListPluginReleases(_ context.Context, name string) ([]coreplugin.Release, error)

func (*MockPluginStore) ListPlugins

func (f *MockPluginStore) ListPlugins(_ context.Context, includeArchived bool) ([]coreplugin.Plugin, error)

func (*MockPluginStore) SetPluginArchived

func (f *MockPluginStore) SetPluginArchived(_ context.Context, name string, archived bool) error

func (*MockPluginStore) UpdatePlugin

func (*MockPluginStore) YankPluginRelease

func (f *MockPluginStore) YankPluginRelease(_ context.Context, name, version, actor, reason string) error

type MockRefreshToken

type MockRefreshToken struct {
	UserID    string
	SessionID string
	Platform  string
	ExpiresAt time.Time
	UsedAt    *time.Time
	RevokedAt *time.Time
}

MockRefreshToken is one issued token in MockRefreshTokenStore.

type MockRefreshTokenStore

type MockRefreshTokenStore struct {
	Tokens map[string]*MockRefreshToken
	// CreateErr and RotateErr force a store failure.
	CreateErr error
	RotateErr error
	// contains filtered or unexported fields
}

MockRefreshTokenStore is an in-memory RefreshTokenStore for tests.

It reproduces the rotation rules the real store enforces — spend on exchange, a grace window for concurrent callers, revoke the session on reuse — because those rules are what the handlers branch on. A mock that always succeeded would let a handler test pass while the endpoint handed a replayed credential a fresh session.

func (*MockRefreshTokenStore) Backdate

func (m *MockRefreshTokenStore) Backdate(plaintext string, by time.Duration) bool

Backdate moves a spent token's used_at further into the past, so a test can put a token outside the rotation grace window without waiting for the clock. It reports whether the token was there to move.

func (*MockRefreshTokenStore) CountUserSessions

func (m *MockRefreshTokenStore) CountUserSessions(_ context.Context, userID string, now time.Time) (int, error)

func (*MockRefreshTokenStore) CreateRefreshToken

func (*MockRefreshTokenStore) DeleteExpiredRefreshTokens

func (m *MockRefreshTokenStore) DeleteExpiredRefreshTokens(_ context.Context, before time.Time) (int64, error)

func (*MockRefreshTokenStore) RevokeRefreshTokenSession

func (m *MockRefreshTokenStore) RevokeRefreshTokenSession(_ context.Context, plaintext string, now time.Time) (string, string, error)

func (*MockRefreshTokenStore) RevokeSession

func (m *MockRefreshTokenStore) RevokeSession(_ context.Context, sessionID string, now time.Time) (int64, error)

func (*MockRefreshTokenStore) RevokeUserSessions

func (m *MockRefreshTokenStore) RevokeUserSessions(_ context.Context, userID string, now time.Time) (int64, error)

func (*MockRefreshTokenStore) RotateRefreshToken

func (m *MockRefreshTokenStore) RotateRefreshToken(_ context.Context, plaintext string, now time.Time, ttl, grace time.Duration) (coreidentity.RotatedRefreshToken, error)

type MockRunOutputLister

type MockRunOutputLister struct {
	List        []coretask.RunOutputListing
	ListErr     error
	OutputFiles map[string][]coretask.RunOutputFile
}

MockRunOutputLister is an in-memory RunOutputLister for tests.

func (*MockRunOutputLister) GetTaskRunOutputFiles

func (m *MockRunOutputLister) GetTaskRunOutputFiles(_ context.Context, taskRunID string) ([]coretask.RunOutputFile, error)

func (*MockRunOutputLister) ListRunOutputsByConversation

func (m *MockRunOutputLister) ListRunOutputsByConversation(_ context.Context, conversationID string, taskID *string) ([]coretask.RunOutputListing, error)

type MockRunOutputStorage

type MockRunOutputStorage struct {
	Results map[string][]byte
	Files   map[string][]byte
}

MockRunOutputStorage is an in-memory blob.RunOutputStorage for tests.

func NewMockRunOutputStorage

func NewMockRunOutputStorage() *MockRunOutputStorage

NewMockRunOutputStorage returns a MockRunOutputStorage ready for use.

func (*MockRunOutputStorage) GetResult

func (m *MockRunOutputStorage) GetResult(_ context.Context, ref blob.RunRef) ([]byte, error)

func (*MockRunOutputStorage) GetRunOutputFile

func (m *MockRunOutputStorage) GetRunOutputFile(_ context.Context, ref blob.RunObjectRef) ([]byte, error)

func (*MockRunOutputStorage) PutResult

func (m *MockRunOutputStorage) PutResult(_ context.Context, ref blob.RunRef, data []byte) error

func (*MockRunOutputStorage) PutRunOutputFile

func (m *MockRunOutputStorage) PutRunOutputFile(_ context.Context, ref blob.RunObjectRef, r io.Reader) error

type MockSystemGrantStore

type MockSystemGrantStore struct {
	Grants []coreidentity.SystemGrant
	// Err, when set, is returned by every read so a caller's behaviour on a
	// store failure can be exercised. An authorization check that fails open
	// on a database error is the bug worth having a test for.
	Err error
}

MockSystemGrantStore is an in-memory coreidentity.SystemGrantStore for tests.

func (*MockSystemGrantStore) ActiveSystemRoles

func (m *MockSystemGrantStore) ActiveSystemRoles(_ context.Context, userID string) ([]string, error)

func (*MockSystemGrantStore) CountActiveSystemGrants

func (m *MockSystemGrantStore) CountActiveSystemGrants(_ context.Context, role string) (int, error)

func (*MockSystemGrantStore) GrantForTest

func (m *MockSystemGrantStore) GrantForTest(userID, role string)

GrantForTest adds an active grant without going through the validation GrantSystemRole applies. Test setup, not a store method.

func (*MockSystemGrantStore) GrantSystemRole

func (m *MockSystemGrantStore) GrantSystemRole(_ context.Context, userID, role, grantedBy string, now time.Time) (*coreidentity.SystemGrant, error)

func (*MockSystemGrantStore) ListSystemGrants

func (m *MockSystemGrantStore) ListSystemGrants(_ context.Context, includeRevoked bool) ([]coreidentity.SystemGrant, error)

func (*MockSystemGrantStore) RevokeSystemRole

func (m *MockSystemGrantStore) RevokeSystemRole(_ context.Context, userID, role string, now time.Time) (bool, error)

type MockTaskResultDeliveryStore

type MockTaskResultDeliveryStore struct {
	Deliveries map[string]*coretask.ResultDelivery
	// EnqueueErr, when set, is returned by every enqueue.
	EnqueueErr error
	// contains filtered or unexported fields
}

MockTaskResultDeliveryStore is an in-memory TaskResultDeliveryStore.

The claim is a real compare-and-set, not a stub that always succeeds: what it exists to prevent is one run being reported twice, and a double that cannot refuse a second claim would let that pass.

func (*MockTaskResultDeliveryStore) ClaimTaskResultDelivery

func (m *MockTaskResultDeliveryStore) ClaimTaskResultDelivery(_ context.Context, taskRunID string, now, nextAttemptAt time.Time) (*coretask.ResultDelivery, error)

func (*MockTaskResultDeliveryStore) EnqueueTaskResultDelivery

func (m *MockTaskResultDeliveryStore) EnqueueTaskResultDelivery(_ context.Context, taskRunID, conversationID string, now time.Time) error

func (*MockTaskResultDeliveryStore) FinishTaskResultDelivery

func (m *MockTaskResultDeliveryStore) FinishTaskResultDelivery(_ context.Context, taskRunID, status string, lastError *string) error

func (*MockTaskResultDeliveryStore) Get

Get returns a copy of one delivery, or nil.

func (*MockTaskResultDeliveryStore) ListDueTaskResultDeliveries

func (m *MockTaskResultDeliveryStore) ListDueTaskResultDeliveries(_ context.Context, now time.Time, limit int) ([]coretask.ResultDelivery, error)

func (*MockTaskResultDeliveryStore) RecordTaskResultDeliveryFailure

func (m *MockTaskResultDeliveryStore) RecordTaskResultDeliveryFailure(_ context.Context, taskRunID, lastError string, nextAttemptAt time.Time) error

type MockTaskRunStore

type MockTaskRunStore struct {
	Runs     []coretask.Run
	TaskList []coretask.Task
	// Artifacts holds the relative paths registered per run, so a test can
	// check that a run's files were kept.
	Artifacts map[string][]string
}

MockTaskRunStore is an in-memory TaskRunStore for tests.

func (*MockTaskRunStore) CountTaskRunsByStatus

func (m *MockTaskRunStore) CountTaskRunsByStatus(_ context.Context) (map[string]int, error)

func (*MockTaskRunStore) CreateTaskRun

func (*MockTaskRunStore) GetActiveTaskRunByTask

func (m *MockTaskRunStore) GetActiveTaskRunByTask(_ context.Context, taskID string) (*coretask.Run, error)

func (*MockTaskRunStore) GetNextPendingTaskRun

func (m *MockTaskRunStore) GetNextPendingTaskRun(_ context.Context) (*coretask.Run, error)

func (*MockTaskRunStore) GetTaskRun

func (m *MockTaskRunStore) GetTaskRun(_ context.Context, taskRunID string) (*coretask.Run, error)

func (*MockTaskRunStore) GetTaskRunWithTask

func (m *MockTaskRunStore) GetTaskRunWithTask(_ context.Context, taskRunID string) (*coretask.Run, *coretask.Task, error)

func (*MockTaskRunStore) ListTaskRunIDsByTasks

func (m *MockTaskRunStore) ListTaskRunIDsByTasks(_ context.Context, taskIDs []string) (map[string][]string, error)

func (*MockTaskRunStore) MarkTaskRunSeen

func (m *MockTaskRunStore) MarkTaskRunSeen(_ context.Context, taskRunID string, seenAt time.Time) error

MarkTaskRunSeen stamps an active run, matching the store's status guard so a test cannot observe a terminal run's timestamp moving.

func (*MockTaskRunStore) RecordTaskRunAgentRevision

func (m *MockTaskRunStore) RecordTaskRunAgentRevision(_ context.Context, taskRunID string, revision int) error

func (*MockTaskRunStore) RecordTaskRunPluginPins

func (m *MockTaskRunStore) RecordTaskRunPluginPins(_ context.Context, taskRunID string, pins []coreplugin.Pin) error

func (*MockTaskRunStore) RequestTaskRunCancel

func (m *MockTaskRunStore) RequestTaskRunCancel(_ context.Context, taskRunID, requestedBy string, requestedAt time.Time) (bool, error)

func (*MockTaskRunStore) TransitionTaskRun

func (m *MockTaskRunStore) TransitionTaskRun(ctx context.Context, in coretask.TransitionRunInput) (bool, error)

func (*MockTaskRunStore) UpdateTaskRunWorkerInfo

func (m *MockTaskRunStore) UpdateTaskRunWorkerInfo(_ context.Context, taskRunID, workerType string, k8sJobName *string, k8sJobCreatedAt *time.Time) error

type MockTaskStore

type MockTaskStore struct {
	List      []coretask.Task
	ListErr   error
	Create    *coretask.Task
	CreateErr error
	// Created records what each CreateTask was asked for. The returned Task
	// drops most of it, so provenance a caller set can only be asserted here.
	Created []coretask.CreateInput
}

MockTaskStore is an in-memory TaskStore for tests.

func (*MockTaskStore) ClaimTask

func (m *MockTaskStore) ClaimTask(_ context.Context, in coretask.ClaimInput) (bool, error)

func (*MockTaskStore) CreateTask

func (m *MockTaskStore) CreateTask(_ context.Context, in *coretask.CreateInput) (*coretask.Task, error)

func (*MockTaskStore) GetTask

func (m *MockTaskStore) GetTask(_ context.Context, taskID string) (*coretask.Task, error)

func (*MockTaskStore) GetTaskBySessionID

func (m *MockTaskStore) GetTaskBySessionID(_ context.Context, sessionID string) (*coretask.Task, error)

func (*MockTaskStore) ListTasksByConversation

func (m *MockTaskStore) ListTasksByConversation(_ context.Context, conversationID string, order string) ([]coretask.Task, error)

func (*MockTaskStore) ListTasksByConversationPaginated

func (m *MockTaskStore) ListTasksByConversationPaginated(_ context.Context, conversationID string, executedOnly bool, limit, offset int) ([]coretask.Task, int, error)

func (*MockTaskStore) ListTasksByIssue

func (m *MockTaskStore) ListTasksByIssue(_ context.Context, issueID string, limit, offset int) ([]coretask.Task, int, error)

func (*MockTaskStore) UpdateTask

func (m *MockTaskStore) UpdateTask(_ context.Context, in coretask.UpdateInput) error

type MockTeamStore

type MockTeamStore struct {
	Teams   []coreteam.Team
	Members []coreteam.Member
}

MockTeamStore is an in-memory TeamStore for tests.

func (*MockTeamStore) AddTeamMember

func (m *MockTeamStore) AddTeamMember(_ context.Context, teamID, userID, role string) (*coreteam.Member, error)

func (*MockTeamStore) CountTeamMembers

func (m *MockTeamStore) CountTeamMembers(_ context.Context, teamIDs []string) (map[string]int, error)

func (*MockTeamStore) CreateTeam

func (m *MockTeamStore) CreateTeam(_ context.Context, name, createdBy, quotaTier string) (*coreteam.Team, error)

func (*MockTeamStore) GetPersonalTeamByUser

func (m *MockTeamStore) GetPersonalTeamByUser(_ context.Context, userID string) (*coreteam.Team, error)

func (*MockTeamStore) GetTeam

func (m *MockTeamStore) GetTeam(_ context.Context, teamID string) (*coreteam.Team, error)

func (*MockTeamStore) ListAllTeams

func (m *MockTeamStore) ListAllTeams(_ context.Context, query string, limit, offset int) ([]coreteam.Team, int, error)

func (*MockTeamStore) ListTeamMembers

func (m *MockTeamStore) ListTeamMembers(_ context.Context, teamID string) ([]coreteam.Member, error)

func (*MockTeamStore) ListTeamsByUser

func (m *MockTeamStore) ListTeamsByUser(_ context.Context, userID string) ([]coreteam.Team, error)

func (*MockTeamStore) RemoveTeamMember

func (m *MockTeamStore) RemoveTeamMember(_ context.Context, teamID, userID string) error

func (*MockTeamStore) SetTeamPluginCuration

func (m *MockTeamStore) SetTeamPluginCuration(_ context.Context, teamID string, mode coreplugin.Curation) error

type MockTierStore

type MockTierStore struct {
	Tier *corequota.Tier
	Err  error
}

MockTierStore returns a fixed tier for GetQuotaTier.

func (*MockTierStore) GetQuotaTier

func (m *MockTierStore) GetQuotaTier(_ context.Context, _ string) (*corequota.Tier, error)

type MockUsageReader

type MockUsageReader struct {
	RunCount    int
	TotalTokens int
	Err         error
}

MockUsageReader returns fixed run count and token total for TeamUsageInWindow.

func (*MockUsageReader) TeamUsageInWindow

func (m *MockUsageReader) TeamUsageInWindow(_ context.Context, _ string, _, _ time.Time) (int, int, error)

type MockUserStore

type MockUserStore struct {
	ByEmail    map[string]*coreidentity.User
	ByID       map[string]*coreidentity.User
	CreateErr  error
	NextUserID int
}

MockUserStore is an in-memory UserStore for tests. Use ByEmail and ByID to pre-seed users; CreateErr and NextUserID for behavior.

func (*MockUserStore) CreateUser

func (m *MockUserStore) CreateUser(_ context.Context, email string, defaultQuotaTier string) (*coreidentity.User, error)

func (*MockUserStore) DisableForTest

func (m *MockUserStore) DisableForTest(userID string, at time.Time)

DisableForTest disables a seeded account. Test setup, not a store method.

func (*MockUserStore) GetUser

func (m *MockUserStore) GetUser(_ context.Context, userID string) (*coreidentity.User, error)

func (*MockUserStore) ListUsers

func (m *MockUserStore) ListUsers(_ context.Context, query string, limit, offset int) ([]coreidentity.User, int, error)

func (*MockUserStore) SetUserDisabled

func (m *MockUserStore) SetUserDisabled(_ context.Context, userID string, disabledAt *time.Time) error

func (*MockUserStore) UpdateLoginMeta

func (m *MockUserStore) UpdateLoginMeta(_ context.Context, userID string, loginAt time.Time, platform string) error

func (*MockUserStore) UserByEmail

func (m *MockUserStore) UserByEmail(_ context.Context, email string) (*coreidentity.User, error)

UserByEmail matches without regard to case, the way the real store's utf8mb4_0900_ai_ci email column does. Login resolves the account by address and nothing compares the two strings afterwards, so a case-sensitive mock would let a regression in that lookup pass here.

type MockUserWebhookKeyStore

type MockUserWebhookKeyStore struct {
	Keys  map[string]string
	Metas map[string][]coreidentity.WebhookKeyMeta
	// contains filtered or unexported fields
}

MockUserWebhookKeyStore is an in-memory UserWebhookKeyStore for tests. Keys maps a plaintext key to the user that owns it.

func (*MockUserWebhookKeyStore) CreateKey

func (m *MockUserWebhookKeyStore) CreateKey(_ context.Context, userID, name string) (string, string, error)

func (*MockUserWebhookKeyStore) GetUserIDByKey

func (m *MockUserWebhookKeyStore) GetUserIDByKey(_ context.Context, plaintextKey string) (string, error)

func (*MockUserWebhookKeyStore) ListKeys

func (*MockUserWebhookKeyStore) RevokeKey

func (m *MockUserWebhookKeyStore) RevokeKey(_ context.Context, userID, keyID string) error

type MockWorkflowStore

type MockWorkflowStore struct {
	Workflows []coreworkflow.Workflow
	Revisions []coreworkflow.Revision
	Runs      []coreworkflow.Run
	StepRuns  []coreworkflow.StepRun
}

MockWorkflowStore is an in-memory WorkflowStore for tests. It records revisions the way the database store does, so a test can assert on history.

func (*MockWorkflowStore) CreateWorkflow

func (m *MockWorkflowStore) CreateWorkflow(_ context.Context, teamID, createdBy, name, description, definition string) (*coreworkflow.Workflow, error)

func (*MockWorkflowStore) CreateWorkflowRun

func (*MockWorkflowStore) CreateWorkflowStepRuns

func (m *MockWorkflowStore) CreateWorkflowStepRuns(_ context.Context, workflowRunID string, steps []coreworkflow.CreateStepRunInput) ([]coreworkflow.StepRun, error)

func (*MockWorkflowStore) GetWorkflow

func (m *MockWorkflowStore) GetWorkflow(_ context.Context, workflowID string) (*coreworkflow.Workflow, error)

func (*MockWorkflowStore) GetWorkflowRevision

func (m *MockWorkflowStore) GetWorkflowRevision(_ context.Context, workflowID string, revision int) (*coreworkflow.Revision, error)

func (*MockWorkflowStore) GetWorkflowRun

func (m *MockWorkflowStore) GetWorkflowRun(_ context.Context, workflowRunID string) (*coreworkflow.Run, error)

func (*MockWorkflowStore) GetWorkflowStepRunByTaskID

func (m *MockWorkflowStore) GetWorkflowStepRunByTaskID(_ context.Context, taskID string) (*coreworkflow.StepRun, error)

func (*MockWorkflowStore) GetWorkflowStepRunByTaskRunID

func (m *MockWorkflowStore) GetWorkflowStepRunByTaskRunID(_ context.Context, taskRunID string) (*coreworkflow.StepRun, error)

func (*MockWorkflowStore) ListWorkflowRevisions

func (m *MockWorkflowStore) ListWorkflowRevisions(_ context.Context, workflowID string, limit, offset int) ([]coreworkflow.Revision, int, error)

func (*MockWorkflowStore) ListWorkflowRunsByIssue

func (m *MockWorkflowStore) ListWorkflowRunsByIssue(_ context.Context, issueID string, limit, offset int) ([]coreworkflow.Run, int, error)

func (*MockWorkflowStore) ListWorkflowRunsByWorkflow

func (m *MockWorkflowStore) ListWorkflowRunsByWorkflow(_ context.Context, workflowID string, limit, offset int) ([]coreworkflow.Run, int, error)

func (*MockWorkflowStore) ListWorkflowStepRuns

func (m *MockWorkflowStore) ListWorkflowStepRuns(_ context.Context, workflowRunID string) ([]coreworkflow.StepRun, error)

func (*MockWorkflowStore) ListWorkflowsByTeam

func (m *MockWorkflowStore) ListWorkflowsByTeam(_ context.Context, teamID string) ([]coreworkflow.Workflow, error)

func (*MockWorkflowStore) UpdateWorkflow

func (m *MockWorkflowStore) UpdateWorkflow(_ context.Context, workflowID, teamID string, in coreworkflow.UpdateInput) (*coreworkflow.Workflow, error)

func (*MockWorkflowStore) UpdateWorkflowRun

func (m *MockWorkflowStore) UpdateWorkflowRun(_ context.Context, workflowRunID string, in coreworkflow.UpdateRunInput) (*coreworkflow.Run, error)

func (*MockWorkflowStore) UpdateWorkflowStepRun

func (m *MockWorkflowStore) UpdateWorkflowStepRun(_ context.Context, stepRunID string, in coreworkflow.UpdateStepRunInput) (*coreworkflow.StepRun, error)

Jump to

Keyboard shortcuts

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