mocks

package
v0.0.0-...-3c0f8ac Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2026 License: OSL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const MockOwnerToken = "mock-owner-token"

MockOwnerToken is the default token MockConfigStore.MarkCollectionStarted returns when no expectation is registered, so existing tests that call it implicitly keep getting a non-empty token to thread through.

Variables

This section is empty.

Functions

This section is empty.

Types

type EmailSenderAPI

type EmailSenderAPI interface {
	SendNotification(ctx context.Context, subject, message string) error
	SendToEmail(ctx context.Context, toEmail, subject, body string) error
	SendNewRecommendationsNotification(ctx context.Context, data email.NotificationData) error
	SendScheduledPurchaseNotification(ctx context.Context, data email.NotificationData) error
	SendPurchaseConfirmation(ctx context.Context, data email.NotificationData) error
	SendPurchaseFailedNotification(ctx context.Context, data email.NotificationData) error
	SendPasswordResetEmail(ctx context.Context, email, resetURL string) error
	SendWelcomeEmail(ctx context.Context, email, dashboardURL, role string) error
	SendPurchaseApprovalRequest(ctx context.Context, data email.NotificationData) error
	SendPurchaseExecutedNotification(ctx context.Context, data email.NotificationData) error
}

EmailSenderAPI defines the interface for email sender operations.

type MockAuthStore

type MockAuthStore struct {
	mock.Mock
}

MockAuthStore is a mock implementation of auth.Store.

func (*MockAuthStore) AdminExists

func (m *MockAuthStore) AdminExists(ctx context.Context) (bool, error)

AdminExists mocks the AdminExists operation.

func (*MockAuthStore) CleanupExpiredSessions

func (m *MockAuthStore) CleanupExpiredSessions(ctx context.Context) error

CleanupExpiredSessions mocks the CleanupExpiredSessions operation.

func (*MockAuthStore) CountGroupMembers

func (m *MockAuthStore) CountGroupMembers(ctx context.Context, groupID string) (int, error)

CountGroupMembers mocks the CountGroupMembers operation.

func (*MockAuthStore) CreateAPIKey

func (m *MockAuthStore) CreateAPIKey(ctx context.Context, key *auth.UserAPIKey) error

CreateAPIKey mocks the CreateAPIKey operation.

func (*MockAuthStore) CreateAdminIfNone

func (m *MockAuthStore) CreateAdminIfNone(ctx context.Context, user *auth.User) (bool, error)

CreateAdminIfNone mocks the CreateAdminIfNone operation.

func (*MockAuthStore) CreateGroup

func (m *MockAuthStore) CreateGroup(ctx context.Context, group *auth.Group) error

CreateGroup mocks the CreateGroup operation.

func (*MockAuthStore) CreateSession

func (m *MockAuthStore) CreateSession(ctx context.Context, session *auth.Session) error

CreateSession mocks the CreateSession operation.

func (*MockAuthStore) CreateUser

func (m *MockAuthStore) CreateUser(ctx context.Context, user *auth.User) error

CreateUser mocks the CreateUser operation.

func (*MockAuthStore) DeleteAPIKey

func (m *MockAuthStore) DeleteAPIKey(ctx context.Context, keyID string) error

DeleteAPIKey mocks the DeleteAPIKey operation.

func (*MockAuthStore) DeleteGroup

func (m *MockAuthStore) DeleteGroup(ctx context.Context, groupID string) error

DeleteGroup mocks the DeleteGroup operation.

func (*MockAuthStore) DeleteSession

func (m *MockAuthStore) DeleteSession(ctx context.Context, token string) error

DeleteSession mocks the DeleteSession operation.

func (*MockAuthStore) DeleteUser

func (m *MockAuthStore) DeleteUser(ctx context.Context, userID string) error

DeleteUser mocks the DeleteUser operation.

func (*MockAuthStore) DeleteUserSessions

func (m *MockAuthStore) DeleteUserSessions(ctx context.Context, userID string) error

DeleteUserSessions mocks the DeleteUserSessions operation.

func (*MockAuthStore) GetAPIKeyByHash

func (m *MockAuthStore) GetAPIKeyByHash(ctx context.Context, keyHash string) (*auth.UserAPIKey, error)

GetAPIKeyByHash mocks the GetAPIKeyByHash operation.

func (*MockAuthStore) GetAPIKeyByID

func (m *MockAuthStore) GetAPIKeyByID(ctx context.Context, keyID string) (*auth.UserAPIKey, error)

GetAPIKeyByID mocks the GetAPIKeyByID operation.

func (*MockAuthStore) GetGroup

func (m *MockAuthStore) GetGroup(ctx context.Context, groupID string) (*auth.Group, error)

GetGroup mocks the GetGroup operation.

func (*MockAuthStore) GetSession

func (m *MockAuthStore) GetSession(ctx context.Context, token string) (*auth.Session, error)

GetSession mocks the GetSession operation.

func (*MockAuthStore) GetUserByEmail

func (m *MockAuthStore) GetUserByEmail(ctx context.Context, email string) (*auth.User, error)

GetUserByEmail mocks the GetUserByEmail operation.

func (*MockAuthStore) GetUserByID

func (m *MockAuthStore) GetUserByID(ctx context.Context, userID string) (*auth.User, error)

GetUserByID mocks the GetUserByID operation.

func (*MockAuthStore) GetUserByResetToken

func (m *MockAuthStore) GetUserByResetToken(ctx context.Context, token string) (*auth.User, error)

GetUserByResetToken mocks the GetUserByResetToken operation.

func (*MockAuthStore) ListAPIKeysByUser

func (m *MockAuthStore) ListAPIKeysByUser(ctx context.Context, userID string) ([]*auth.UserAPIKey, error)

ListAPIKeysByUser mocks the ListAPIKeysByUser operation.

func (*MockAuthStore) ListGroups

func (m *MockAuthStore) ListGroups(ctx context.Context) ([]auth.Group, error)

ListGroups mocks the ListGroups operation.

func (*MockAuthStore) ListUsers

func (m *MockAuthStore) ListUsers(ctx context.Context) ([]auth.User, error)

ListUsers mocks the ListUsers operation.

func (*MockAuthStore) Ping

func (m *MockAuthStore) Ping(ctx context.Context) error

Ping mocks the Ping operation.

func (*MockAuthStore) RecordAPIKeyUsage

func (m *MockAuthStore) RecordAPIKeyUsage(ctx context.Context, keyID string, delta int64) error

RecordAPIKeyUsage mocks the RecordAPIKeyUsage operation.

func (*MockAuthStore) UpdateAPIKey

func (m *MockAuthStore) UpdateAPIKey(ctx context.Context, key *auth.UserAPIKey) error

UpdateAPIKey mocks the UpdateAPIKey operation.

func (*MockAuthStore) UpdateAPIKeyLastUsed

func (m *MockAuthStore) UpdateAPIKeyLastUsed(ctx context.Context, keyID string) error

UpdateAPIKeyLastUsed mocks the UpdateAPIKeyLastUsed operation.

func (*MockAuthStore) UpdateGroup

func (m *MockAuthStore) UpdateGroup(ctx context.Context, group *auth.Group) error

UpdateGroup mocks the UpdateGroup operation.

func (*MockAuthStore) UpdateUser

func (m *MockAuthStore) UpdateUser(ctx context.Context, user *auth.User) error

UpdateUser mocks the UpdateUser operation.

type MockConfigStore

type MockConfigStore struct {
	GetPurchasePlanFn                   func(ctx context.Context, planID string) (*config.PurchasePlan, error)
	GetCloudAccountFn                   func(ctx context.Context, id string) (*config.CloudAccount, error)
	GetCloudAccountByExternalIDFn       func(ctx context.Context, provider, externalID string) (*config.CloudAccount, error)
	DeleteCloudAccountFn                func(ctx context.Context, id string) error
	ListCloudAccountsFn                 func(ctx context.Context, filter config.CloudAccountFilter) ([]config.CloudAccount, error)
	CreateCloudAccountFn                func(ctx context.Context, account *config.CloudAccount) error
	SetPlanAccountsFn                   func(ctx context.Context, planID string, accountIDs []string) error
	GetPlanAccountsFn                   func(ctx context.Context, planID string) ([]config.CloudAccount, error)
	SaveAccountServiceOverrideFn        func(ctx context.Context, override *config.AccountServiceOverride) error
	CountPendingExecutionsForAccountFn  func(ctx context.Context, accountID string) (int, error)
	ListPendingExecutionIDsForAccountFn func(ctx context.Context, accountID string) ([]string, error)
	SavePurchaseExecutionFn             func(ctx context.Context, exec *config.PurchaseExecution) error
	GetUserEmailByIDFn                  func(ctx context.Context, userID string) (string, error)
	mock.Mock
	// contains filtered or unexported fields
}

MockConfigStore is a shared testify-based mock for config.StoreInterface.

Most methods dispatch through m.Called only when an expectation has been registered via .On(). Methods that pre-existing tests call implicitly (without expectations) default to sensible zero-values so those tests keep working without changes. The "default or dispatch" behavior is controlled by the isExpected helper at the bottom of this file.

Fn-override fields allow tests to inject behavior without registering testify expectations. The precedence order for every overridable method is:

  1. FnField (non-nil closure wins first)
  2. Registered .On() expectation (dispatches through m.Called)
  3. Hardcoded default (zero-value / sensible stub)

Because paths 1 and 3 never reach m.Called, every method records its own invocation in callLog before branching, and AssertCalled / AssertNotCalled / AssertNumberOfCalls read that log instead of mock.Mock.Calls. See assertions.go for why reading mock.Mock.Calls made those assertions unfailable.

func (*MockConfigStore) AssertCalled

func (m *MockConfigStore) AssertCalled(t mock.TestingT, method string, arguments ...interface{}) bool

AssertCalled asserts that method was invoked with arguments satisfying the given matchers. It shadows the promoted testify method so it reads the complete call log rather than mock.Mock.Calls; pass no arguments to assert the method was called at all.

mock.TestingT has no Helper method, so the assertion helpers type-assert for it inline. t.Helper() marks its own caller, so delegating that to a shared function would report every failure at that function's line instead of the assertion's call site.

func (*MockConfigStore) AssertNotCalled

func (m *MockConfigStore) AssertNotCalled(t mock.TestingT, method string, arguments ...interface{}) bool

AssertNotCalled asserts that method was never invoked with arguments satisfying the given matchers. It shadows the promoted testify method so it reads the complete call log rather than mock.Mock.Calls; pass no arguments to assert the method was not called at all.

func (*MockConfigStore) AssertNumberOfCalls

func (m *MockConfigStore) AssertNumberOfCalls(t mock.TestingT, method string, expectedCalls int) bool

AssertNumberOfCalls asserts how many times method was invoked, with any arguments. It shadows the promoted testify method so it reads the complete call log rather than mock.Mock.Calls.

func (*MockConfigStore) CancelAllPendingExchanges

func (m *MockConfigStore) CancelAllPendingExchanges(ctx context.Context) (int64, error)

func (*MockConfigStore) CancelExecutionAtomic

func (m *MockConfigStore) CancelExecutionAtomic(ctx context.Context, tx pgx.Tx, executionID string, cancelledBy *string) (bool, string, error)

CancelExecutionAtomic mocks the CancelExecutionAtomic operation. Defaults to (true, "cancelled", nil) when no expectation is registered so tests that only need the happy path don't require explicit mock setup. Tests exercising the CAS-race path (zero rows affected) register an expectation that returns (false, <racing_status>, nil).

func (*MockConfigStore) CancelPendingExchangesByOrigin

func (m *MockConfigStore) CancelPendingExchangesByOrigin(ctx context.Context, origin common.ExchangeOrigin) (int64, error)

func (*MockConfigStore) CancelScheduledExecutionAtomic

func (m *MockConfigStore) CancelScheduledExecutionAtomic(ctx context.Context, tx pgx.Tx, executionID string, cancelledBy *string) (bool, string, error)

CancelScheduledExecutionAtomic mocks the CancelScheduledExecutionAtomic operation (Gmail-style pre-fire delay revoke, issue #290 wave-2). Default is the happy path (true, "cancelled", nil) so the scheduled-revoke tests inherit the same low-ceremony pattern as CancelExecutionAtomic above. Tests exercising the CAS-race path (scheduler tick already fired) register an expectation that returns (false, <racing_status>, nil), typically (false, "approved", nil) to simulate the scheduler winning the race.

func (*MockConfigStore) ClaimMarketplaceListingSlot

func (m *MockConfigStore) ClaimMarketplaceListingSlot(ctx context.Context, purchaseID string) (bool, error)

ClaimMarketplaceListingSlot mocks the atomic listing-slot claim (issue #292).

func (*MockConfigStore) ClaimRIExchangeIdempotencyKey

func (m *MockConfigStore) ClaimRIExchangeIdempotencyKey(ctx context.Context, key string, window time.Duration) (bool, error)

ClaimRIExchangeIdempotencyKey mocks the atomic RI exchange submit claim (issue #1642). With no registered expectation it defaults to "this call won the claim" so the many pre-existing execute-path tests, whose subject is a gate upstream of the claim, keep exercising the commit call. Tests whose subject IS the claim register an explicit expectation and assert on it.

func (*MockConfigStore) CleanupOldExecutions

func (m *MockConfigStore) CleanupOldExecutions(ctx context.Context, retentionDays int) (int64, error)

CleanupOldExecutions mocks the CleanupOldExecutions operation.

func (*MockConfigStore) ClearCollectionStarted

func (m *MockConfigStore) ClearCollectionStarted(ctx context.Context, token string) error

ClearCollectionStarted mocks the ClearCollectionStarted operation. Defaults to nil when no expectation is registered.

func (*MockConfigStore) ClearRevocationInFlight

func (m *MockConfigStore) ClearRevocationInFlight(ctx context.Context, purchaseID string) error

ClearRevocationInFlight mocks ClearRevocationInFlight (issue #290 second-wave CR Finding D). Uses the isExpected default-or-dispatch pattern: tests that only test error paths where Azure never actually returned do not need to register an expectation.

func (*MockConfigStore) CompletePlanStep

func (m *MockConfigStore) CompletePlanStep(ctx context.Context, planID string, stepNumber int) error

CompletePlanStep mocks the idempotent ramp-step advance operation.

func (*MockConfigStore) CompleteRIExchange

func (m *MockConfigStore) CompleteRIExchange(ctx context.Context, id, exchangeID string) error

func (*MockConfigStore) CompleteRIExchangeWithPayment

func (m *MockConfigStore) CompleteRIExchangeWithPayment(ctx context.Context, id, exchangeID, acceptedPaymentDue string) error

func (*MockConfigStore) CountExecutionsByPlanAndStatus

func (m *MockConfigStore) CountExecutionsByPlanAndStatus(ctx context.Context, statuses []string, since time.Time) (map[string]config.ExecutionStatusCounts, error)

CountExecutionsByPlanAndStatus mocks the CountExecutionsByPlanAndStatus operation.

func (*MockConfigStore) CountPendingExecutionsForAccount

func (m *MockConfigStore) CountPendingExecutionsForAccount(ctx context.Context, accountID string) (int, error)

CountPendingExecutionsForAccount mocks the CountPendingExecutionsForAccount operation. Defaults to (0, nil) when no Fn is set and no expectation is registered.

func (*MockConfigStore) CreateAccountRegistration

func (m *MockConfigStore) CreateAccountRegistration(ctx context.Context, reg *config.AccountRegistration) error

func (*MockConfigStore) CreateCloudAccount

func (m *MockConfigStore) CreateCloudAccount(ctx context.Context, account *config.CloudAccount) error

func (*MockConfigStore) CreatePurchasePlan

func (m *MockConfigStore) CreatePurchasePlan(ctx context.Context, plan *config.PurchasePlan) error

CreatePurchasePlan mocks the CreatePurchasePlan operation.

func (*MockConfigStore) CreateSuppression

func (m *MockConfigStore) CreateSuppression(ctx context.Context, sup *config.PurchaseSuppression) error

func (*MockConfigStore) CreateSuppressionTx

func (m *MockConfigStore) CreateSuppressionTx(ctx context.Context, tx pgx.Tx, sup *config.PurchaseSuppression) error

func (*MockConfigStore) DeleteAccountCredentials

func (m *MockConfigStore) DeleteAccountCredentials(ctx context.Context, accountID string) error

func (*MockConfigStore) DeleteAccountRegistration

func (m *MockConfigStore) DeleteAccountRegistration(ctx context.Context, id string) error

func (*MockConfigStore) DeleteAccountServiceOverride

func (m *MockConfigStore) DeleteAccountServiceOverride(ctx context.Context, accountID, provider, service string) error

func (*MockConfigStore) DeleteCloudAccount

func (m *MockConfigStore) DeleteCloudAccount(ctx context.Context, id string) error

func (*MockConfigStore) DeletePurchasePlan

func (m *MockConfigStore) DeletePurchasePlan(ctx context.Context, planID string) error

DeletePurchasePlan mocks the DeletePurchasePlan operation.

func (*MockConfigStore) DeleteSuppressionsByExecution

func (m *MockConfigStore) DeleteSuppressionsByExecution(ctx context.Context, executionID string) error

func (*MockConfigStore) DeleteSuppressionsByExecutionTx

func (m *MockConfigStore) DeleteSuppressionsByExecutionTx(ctx context.Context, tx pgx.Tx, executionID string) error

func (*MockConfigStore) FailRIExchange

func (m *MockConfigStore) FailRIExchange(ctx context.Context, id, errorMsg string) error

func (*MockConfigStore) FlipPurchaseRevocationInFlight

func (m *MockConfigStore) FlipPurchaseRevocationInFlight(ctx context.Context, purchaseID string) error

FlipPurchaseRevocationInFlight mocks FlipPurchaseRevocationInFlight (issue #290 Finding #6). Uses the isExpected default-or-dispatch pattern: tests that only verify MarkPurchaseRevoked do not need to set an expectation for this best-effort call.

func (*MockConfigStore) GetAccountCredential

func (m *MockConfigStore) GetAccountCredential(ctx context.Context, accountID, credentialType string) (string, error)

func (*MockConfigStore) GetAccountRegistration

func (m *MockConfigStore) GetAccountRegistration(ctx context.Context, id string) (*config.AccountRegistration, error)

func (*MockConfigStore) GetAccountRegistrationByToken

func (m *MockConfigStore) GetAccountRegistrationByToken(ctx context.Context, token string) (*config.AccountRegistration, error)

func (*MockConfigStore) GetAccountServiceOverride

func (m *MockConfigStore) GetAccountServiceOverride(ctx context.Context, accountID, provider, service string) (*config.AccountServiceOverride, error)

func (*MockConfigStore) GetActivePurchaseHistory

func (m *MockConfigStore) GetActivePurchaseHistory(ctx context.Context, asOf time.Time, accountIDs []string, externalIDsByProvider map[string][]string) ([]config.PurchaseHistoryRecord, error)

GetActivePurchaseHistory mocks the GetActivePurchaseHistory operation.

func (*MockConfigStore) GetAllPurchaseHistory

func (m *MockConfigStore) GetAllPurchaseHistory(ctx context.Context, limit int) ([]config.PurchaseHistoryRecord, error)

GetAllPurchaseHistory mocks the GetAllPurchaseHistory operation.

func (*MockConfigStore) GetCloudAccount

func (m *MockConfigStore) GetCloudAccount(ctx context.Context, id string) (*config.CloudAccount, error)

GetCloudAccount defaults to returning a minimal stub {ID: id} when no Fn is set and no expectation is registered, so tests that don't care about account fields keep working without explicit setup.

func (*MockConfigStore) GetCloudAccountByExternalID

func (m *MockConfigStore) GetCloudAccountByExternalID(ctx context.Context, provider, externalID string) (*config.CloudAccount, error)

func (*MockConfigStore) GetExecutionByID

func (m *MockConfigStore) GetExecutionByID(ctx context.Context, executionID string) (*config.PurchaseExecution, error)

GetExecutionByID mocks the GetExecutionByID operation.

func (*MockConfigStore) GetExecutionByPlanAndDate

func (m *MockConfigStore) GetExecutionByPlanAndDate(ctx context.Context, planID string, scheduledDate time.Time) (*config.PurchaseExecution, error)

GetExecutionByPlanAndDate mocks the GetExecutionByPlanAndDate operation.

func (*MockConfigStore) GetExecutionsByStatuses

func (m *MockConfigStore) GetExecutionsByStatuses(ctx context.Context, statuses []string, limit int) ([]config.PurchaseExecution, error)

GetExecutionsByStatuses mocks the GetExecutionsByStatuses operation.

func (*MockConfigStore) GetGlobalConfig

func (m *MockConfigStore) GetGlobalConfig(ctx context.Context) (*config.GlobalConfig, error)

GetGlobalConfig mocks the GetGlobalConfig operation. Returns an empty GlobalConfig when no expectation is registered so callers that only need default field values don't require explicit mock setup.

func (*MockConfigStore) GetInFlightLadderCommitUSDHr

func (m *MockConfigStore) GetInFlightLadderCommitUSDHr(ctx context.Context, configID string) (*float64, error)

GetInFlightLadderCommitUSDHr mocks the GetInFlightLadderCommitUSDHr operation. Returns a pointer to zero (no in-flight commitment) when no expectation is registered, matching the happy-path default.

func (*MockConfigStore) GetLadderConfig

func (m *MockConfigStore) GetLadderConfig(ctx context.Context, cloudAccountID, provider string) (*config.LadderConfigDB, error)

GetLadderConfig mocks the GetLadderConfig operation. Returns (nil, nil) when no expectation is registered.

func (*MockConfigStore) GetLadderConfigs

func (m *MockConfigStore) GetLadderConfigs(ctx context.Context) ([]config.LadderConfigDB, error)

GetLadderConfigs mocks the GetLadderConfigs operation. Returns an empty slice when no expectation is registered so tests that do not exercise laddering keep working without mock setup.

func (*MockConfigStore) GetLadderRun

func (m *MockConfigStore) GetLadderRun(ctx context.Context, id string) (*config.LadderRunDB, error)

GetLadderRun mocks the GetLadderRun operation. Returns (nil, nil) when no expectation is registered.

func (*MockConfigStore) GetPendingExecutions

func (m *MockConfigStore) GetPendingExecutions(ctx context.Context) ([]config.PurchaseExecution, error)

GetPendingExecutions mocks the GetPendingExecutions operation.

func (*MockConfigStore) GetPendingExecutionsTx

func (m *MockConfigStore) GetPendingExecutionsTx(ctx context.Context, tx pgx.Tx) ([]config.PurchaseExecution, error)

GetPendingExecutionsTx mocks the GetPendingExecutionsTx operation. Falls back to GetPendingExecutions when no explicit expectation is registered (same pattern as SavePurchaseExecutionTx) so existing tests that exercise the WithTx path transparently get the same pending-execution list.

func (*MockConfigStore) GetPlanAccounts

func (m *MockConfigStore) GetPlanAccounts(ctx context.Context, planID string) ([]config.CloudAccount, error)

func (*MockConfigStore) GetPlannedExecutions

func (m *MockConfigStore) GetPlannedExecutions(ctx context.Context, statuses []string, limit int) ([]config.PurchaseExecution, error)

GetPlannedExecutions mocks the GetPlannedExecutions operation.

func (*MockConfigStore) GetPurchaseHistory

func (m *MockConfigStore) GetPurchaseHistory(ctx context.Context, accountID string, limit int) ([]config.PurchaseHistoryRecord, error)

GetPurchaseHistory mocks the GetPurchaseHistory operation.

func (*MockConfigStore) GetPurchaseHistoryByPurchaseID

func (m *MockConfigStore) GetPurchaseHistoryByPurchaseID(ctx context.Context, purchaseID string) (*config.PurchaseHistoryRecord, error)

GetPurchaseHistoryByPurchaseID mocks the single-row lookup by purchase_id (issues #290, #292).

func (*MockConfigStore) GetPurchaseHistoryFiltered

func (m *MockConfigStore) GetPurchaseHistoryFiltered(ctx context.Context, filter config.PurchaseHistoryFilter) ([]config.PurchaseHistoryRecord, error)

GetPurchaseHistoryFiltered mocks the GetPurchaseHistoryFiltered operation (issue #701).

func (*MockConfigStore) GetPurchaseHistoryInFlight

func (m *MockConfigStore) GetPurchaseHistoryInFlight(ctx context.Context) ([]*config.PurchaseHistoryRecord, error)

GetPurchaseHistoryInFlight mocks GetPurchaseHistoryInFlight (issue #290 Finding #6).

func (*MockConfigStore) GetPurchasePlan

func (m *MockConfigStore) GetPurchasePlan(ctx context.Context, planID string) (*config.PurchasePlan, error)

GetPurchasePlan mocks the GetPurchasePlan operation. When GetPurchasePlanFn is non-nil it takes priority. When no expectation is registered a minimal plan stub {ID: planID} is returned so tests that don't care about the plan fields keep working without explicit setup.

func (*MockConfigStore) GetRIExchangeDailySpend

func (m *MockConfigStore) GetRIExchangeDailySpend(ctx context.Context, date time.Time) (string, error)

func (*MockConfigStore) GetRIExchangeHistory

func (m *MockConfigStore) GetRIExchangeHistory(ctx context.Context, since time.Time, limit int) ([]config.RIExchangeRecord, error)

func (*MockConfigStore) GetRIExchangeRecord

func (m *MockConfigStore) GetRIExchangeRecord(ctx context.Context, id string) (*config.RIExchangeRecord, error)

func (*MockConfigStore) GetRIExchangeRecordByToken

func (m *MockConfigStore) GetRIExchangeRecordByToken(ctx context.Context, token string) (*config.RIExchangeRecord, error)

func (*MockConfigStore) GetRIUtilizationCache

func (m *MockConfigStore) GetRIUtilizationCache(ctx context.Context, region string, lookbackDays int) (*config.RIUtilizationCacheEntry, error)

func (*MockConfigStore) GetRecommendationsFreshness

func (m *MockConfigStore) GetRecommendationsFreshness(ctx context.Context) (*config.RecommendationsFreshness, error)

func (*MockConfigStore) GetScheduledExecutionsDue

func (m *MockConfigStore) GetScheduledExecutionsDue(ctx context.Context) ([]config.PurchaseExecution, error)

GetScheduledExecutionsDue mocks the GetScheduledExecutionsDue operation. Defaults to (nil, nil) when no expectation is registered so existing scheduler tests that don't exercise the pre-fire delay path keep working without changes.

func (*MockConfigStore) GetServiceConfig

func (m *MockConfigStore) GetServiceConfig(ctx context.Context, provider, service string) (*config.ServiceConfig, error)

GetServiceConfig mocks the GetServiceConfig operation.

func (*MockConfigStore) GetStaleApprovedExecutions

func (m *MockConfigStore) GetStaleApprovedExecutions(ctx context.Context, olderThan time.Duration) ([]config.PurchaseExecution, error)

GetStaleApprovedExecutions mocks the GetStaleApprovedExecutions operation.

func (*MockConfigStore) GetStaleProcessingExchanges

func (m *MockConfigStore) GetStaleProcessingExchanges(ctx context.Context, olderThan time.Duration) ([]config.RIExchangeRecord, error)

func (*MockConfigStore) GetStuckRampSteps

func (m *MockConfigStore) GetStuckRampSteps(ctx context.Context) (map[string]config.RampStepBlock, error)

GetStuckRampSteps mocks the stuck-ramp report backing plan health. Unregistered by default so the many tests that only care about the health score's execution counts stay green: no stuck steps is the shape of a plan with nothing wrong with it.

func (*MockConfigStore) GetUserEmailByID

func (m *MockConfigStore) GetUserEmailByID(ctx context.Context, userID string) (string, error)

GetUserEmailByID mocks the GetUserEmailByID operation. Defaults to ("", nil) when no Fn is set and no expectation is registered, so tests that never exercise the 4-eyes identity-resolution path (mode off, the default) don't need to stub this method.

func (*MockConfigStore) HasAccountCredentials

func (m *MockConfigStore) HasAccountCredentials(ctx context.Context, accountID string) (bool, error)

func (*MockConfigStore) IsNotificationMuted

func (m *MockConfigStore) IsNotificationMuted(ctx context.Context, recipientEmail, scope string) (bool, error)

IsNotificationMuted mocks the IsNotificationMuted operation. Defaults to (false, nil) when no expectation is registered.

func (*MockConfigStore) LatestLadderRunStartedAt

func (m *MockConfigStore) LatestLadderRunStartedAt(ctx context.Context, configID string) (*time.Time, error)

LatestLadderRunStartedAt mocks the LatestLadderRunStartedAt operation. Returns (nil, nil) when no expectation is registered.

func (*MockConfigStore) ListAccountRegistrations

func (m *MockConfigStore) ListAccountRegistrations(ctx context.Context, filter config.AccountRegistrationFilter) ([]config.AccountRegistration, error)

func (*MockConfigStore) ListAccountServiceOverrides

func (m *MockConfigStore) ListAccountServiceOverrides(ctx context.Context, accountID string) ([]config.AccountServiceOverride, error)

func (*MockConfigStore) ListActiveSuppressions

func (m *MockConfigStore) ListActiveSuppressions(ctx context.Context) ([]config.PurchaseSuppression, error)

func (*MockConfigStore) ListCloudAccounts

func (m *MockConfigStore) ListCloudAccounts(ctx context.Context, filter config.CloudAccountFilter) ([]config.CloudAccount, error)

func (*MockConfigStore) ListPendingExecutionIDsForAccount

func (m *MockConfigStore) ListPendingExecutionIDsForAccount(ctx context.Context, accountID string) ([]string, error)

ListPendingExecutionIDsForAccount mocks the ListPendingExecutionIDsForAccount operation. Defaults to (nil, nil) when no Fn is set and no expectation is registered.

func (*MockConfigStore) ListPurchasePlans

func (m *MockConfigStore) ListPurchasePlans(ctx context.Context, filter config.PurchasePlanFilter) ([]config.PurchasePlan, error)

ListPurchasePlans mocks the ListPurchasePlans operation.

func (*MockConfigStore) ListServiceConfigs

func (m *MockConfigStore) ListServiceConfigs(ctx context.Context) ([]config.ServiceConfig, error)

ListServiceConfigs mocks the ListServiceConfigs operation.

func (*MockConfigStore) ListStoredRecommendations

func (m *MockConfigStore) ListStoredRecommendations(ctx context.Context, filter config.RecommendationFilter) ([]config.RecommendationRecord, error)

func (*MockConfigStore) ListStuckExecutions

func (m *MockConfigStore) ListStuckExecutions(ctx context.Context, statuses []string, olderThan time.Duration) ([]config.PurchaseExecution, error)

ListStuckExecutions mocks the ListStuckExecutions operation.

func (*MockConfigStore) LockPurchasePlanTx

func (m *MockConfigStore) LockPurchasePlanTx(ctx context.Context, tx pgx.Tx, planID string) (*config.PurchasePlan, error)

LockPurchasePlanTx mocks the per-plan ramp lock. Falls back to GetPurchasePlan when no expectation is registered, so tests that only care about what the transaction writes keep working: the lock is a concurrency property, and a mock cannot hold one anyway. The real contract is measured against Postgres in the api integration tests.

func (*MockConfigStore) MarkCollectionStarted

func (m *MockConfigStore) MarkCollectionStarted(ctx context.Context) (token string, ok bool, err error)

MarkCollectionStarted mocks the MarkCollectionStarted operation. Defaults to (MockOwnerToken, true, nil) when no expectation is registered.

func (*MockConfigStore) MarkPurchaseRevoked

func (m *MockConfigStore) MarkPurchaseRevoked(ctx context.Context, purchaseID string, revokedAt time.Time, revokedVia, supportCaseID string, calcRefundAmount *float64, calcRefundCurrency string) error

MarkPurchaseRevoked mocks the MarkPurchaseRevoked operation (issue #290).

func (*MockConfigStore) OccupiedRampStepsInRangeTx

func (m *MockConfigStore) OccupiedRampStepsInRangeTx(ctx context.Context, tx pgx.Tx, planID string, from, to int) ([]int, error)

OccupiedRampStepsInRangeTx mocks the already-covered ramp-step probe. Unregistered by default so the many create-purchases tests that predate the probe keep exercising the create path: no occupied steps in range is the shape of a plan whose next steps are still unscheduled, which is what those tests set up.

func (*MockConfigStore) ReplaceRecommendations

func (m *MockConfigStore) ReplaceRecommendations(ctx context.Context, collectedAt time.Time, recs []config.RecommendationRecord) error

func (*MockConfigStore) SaveAccountCredential

func (m *MockConfigStore) SaveAccountCredential(ctx context.Context, accountID, credentialType, encryptedBlob string) error

func (*MockConfigStore) SaveAccountServiceOverride

func (m *MockConfigStore) SaveAccountServiceOverride(ctx context.Context, override *config.AccountServiceOverride) error

func (*MockConfigStore) SaveGlobalConfig

func (m *MockConfigStore) SaveGlobalConfig(ctx context.Context, cfg *config.GlobalConfig) error

SaveGlobalConfig mocks the SaveGlobalConfig operation.

func (*MockConfigStore) SaveLadderRun

func (m *MockConfigStore) SaveLadderRun(ctx context.Context, run *config.LadderRunDB) (*config.LadderRunDB, error)

SaveLadderRun mocks the SaveLadderRun operation. Returns (nil, nil) when no expectation is registered.

func (*MockConfigStore) SaveLadderRunWithTranches

func (m *MockConfigStore) SaveLadderRunWithTranches(ctx context.Context, run *config.LadderRunDB, tranches []config.LadderTrancheDB) (*config.LadderRunDB, error)

SaveLadderRunWithTranches mocks the SaveLadderRunWithTranches operation. Returns the run unchanged (transaction succeeds) when no expectation is registered, so tests that only care about other calls stay green.

func (*MockConfigStore) SaveLadderTranches

func (m *MockConfigStore) SaveLadderTranches(ctx context.Context, tranches []config.LadderTrancheDB) error

SaveLadderTranches mocks the SaveLadderTranches operation. Returns nil (no-op) when no expectation is registered.

func (*MockConfigStore) SavePurchaseExecution

func (m *MockConfigStore) SavePurchaseExecution(ctx context.Context, exec *config.PurchaseExecution) error

SavePurchaseExecution mocks the SavePurchaseExecution operation. SavePurchaseExecutionFn takes priority when non-nil.

func (*MockConfigStore) SavePurchaseExecutionTx

func (m *MockConfigStore) SavePurchaseExecutionTx(ctx context.Context, tx pgx.Tx, execution *config.PurchaseExecution) error

func (*MockConfigStore) SavePurchaseHistory

func (m *MockConfigStore) SavePurchaseHistory(ctx context.Context, record *config.PurchaseHistoryRecord) error

SavePurchaseHistory mocks the SavePurchaseHistory operation.

func (*MockConfigStore) SaveRIExchangeRecord

func (m *MockConfigStore) SaveRIExchangeRecord(ctx context.Context, record *config.RIExchangeRecord) error

func (*MockConfigStore) SaveServiceConfig

func (m *MockConfigStore) SaveServiceConfig(ctx context.Context, cfg *config.ServiceConfig) error

SaveServiceConfig mocks the SaveServiceConfig operation.

func (*MockConfigStore) SetCancelledBy

func (m *MockConfigStore) SetCancelledBy(ctx context.Context, executionID, cancelledBy string) error

SetCancelledBy mocks the SetCancelledBy targeted-update operation.

func (*MockConfigStore) SetPlanAccounts

func (m *MockConfigStore) SetPlanAccounts(ctx context.Context, planID string, accountIDs []string) error

func (*MockConfigStore) SetRecommendationsCollectionError

func (m *MockConfigStore) SetRecommendationsCollectionError(ctx context.Context, errMsg string) error

func (*MockConfigStore) StampOfferingClass

func (m *MockConfigStore) StampOfferingClass(ctx context.Context, purchaseID, offeringClass string) error

StampOfferingClass mocks persisting the offering_class fetched from AWS (issue #292).

func (*MockConfigStore) StampRIExchangeApprovedBy

func (m *MockConfigStore) StampRIExchangeApprovedBy(ctx context.Context, id, approverEmail string) error

StampRIExchangeApprovedBy mocks the StampRIExchangeApprovedBy operation.

func (*MockConfigStore) TransitionExecutionStatus

func (m *MockConfigStore) TransitionExecutionStatus(ctx context.Context, executionID string, fromStatuses []string, toStatus string, actor *string) (*config.PurchaseExecution, error)

TransitionExecutionStatus mocks the TransitionExecutionStatus operation.

func (*MockConfigStore) TransitionLadderRunStatus

func (m *MockConfigStore) TransitionLadderRunStatus(ctx context.Context, id string, fromStatuses []ladder.RunStatus, toStatus ladder.RunStatus) (*config.LadderRunDB, error)

TransitionLadderRunStatus mocks the TransitionLadderRunStatus operation. Returns (nil, nil) when no expectation is registered (CAS race-lost path).

func (*MockConfigStore) TransitionRIExchangeStatus

func (m *MockConfigStore) TransitionRIExchangeStatus(ctx context.Context, id, fromStatus, toStatus string, actor *string) (*config.RIExchangeRecord, error)

func (*MockConfigStore) TransitionRegistrationStatus

func (m *MockConfigStore) TransitionRegistrationStatus(ctx context.Context, reg *config.AccountRegistration, fromStatus string, actor *string) error

func (*MockConfigStore) UpdateAccountRegistration

func (m *MockConfigStore) UpdateAccountRegistration(ctx context.Context, reg *config.AccountRegistration) error

func (*MockConfigStore) UpdateCloudAccount

func (m *MockConfigStore) UpdateCloudAccount(ctx context.Context, account *config.CloudAccount) error

func (*MockConfigStore) UpdateGlobalConfigAtomic

func (m *MockConfigStore) UpdateGlobalConfigAtomic(ctx context.Context, apply func(*config.GlobalConfig) error) (*config.GlobalConfig, error)

UpdateGlobalConfigAtomic mocks the atomic read-modify-write. When an expectation is registered it dispatches through m.Called (tests can drive the apply closure via a Run callback). Otherwise it emulates the real locked read-modify-write by routing through the mocked GetGlobalConfig + apply + SaveGlobalConfig, so existing tests that seed those two continue to work.

func (*MockConfigStore) UpdatePurchaseHistoryListing

func (m *MockConfigStore) UpdatePurchaseHistoryListing(ctx context.Context, purchaseID, listingID, listingState string) error

UpdatePurchaseHistoryListing mocks stamping listing_id and listing_state (issue #292).

func (*MockConfigStore) UpdatePurchasePlan

func (m *MockConfigStore) UpdatePurchasePlan(ctx context.Context, plan *config.PurchasePlan) error

UpdatePurchasePlan mocks the UpdatePurchasePlan operation.

func (*MockConfigStore) UpdatePurchasePlanTx

func (m *MockConfigStore) UpdatePurchasePlanTx(ctx context.Context, tx pgx.Tx, plan *config.PurchasePlan) error

UpdatePurchasePlanTx mocks the UpdatePurchasePlanTx operation. Falls back to UpdatePurchasePlan when no expectation is registered so tests that don't care about the Tx variant stay green -- same pattern as SavePurchaseExecutionTx below.

func (*MockConfigStore) UpsertLadderConfig

func (m *MockConfigStore) UpsertLadderConfig(ctx context.Context, cfg *config.LadderConfigDB) (*config.LadderConfigDB, error)

UpsertLadderConfig mocks the UpsertLadderConfig operation.

func (*MockConfigStore) UpsertNotificationMute

func (m *MockConfigStore) UpsertNotificationMute(ctx context.Context, recipientEmail, scope, unmuteToken string) error

UpsertNotificationMute mocks the UpsertNotificationMute operation. Defaults to nil when no expectation is registered.

func (*MockConfigStore) UpsertRIUtilizationCache

func (m *MockConfigStore) UpsertRIUtilizationCache(ctx context.Context, region string, lookbackDays int, payload []byte, fetchedAt time.Time) error

func (*MockConfigStore) UpsertRecommendations

func (m *MockConfigStore) UpsertRecommendations(ctx context.Context, collectedAt time.Time, recs []config.RecommendationRecord, successfulCollects []config.SuccessfulCollect) error

func (*MockConfigStore) WithTx

func (m *MockConfigStore) WithTx(ctx context.Context, fn func(tx pgx.Tx) error) error

WithTx invokes fn with a nil sentinel Tx so tests exercise the inner *Tx mocks directly. Tests that want to assert on WithTx itself register .On("WithTx", ...) and that takes precedence.

type MockEmailSender

type MockEmailSender struct {
	mock.Mock
}

MockEmailSender is a mock implementation of email.Sender.

func (*MockEmailSender) SendNewRecommendationsNotification

func (m *MockEmailSender) SendNewRecommendationsNotification(ctx context.Context, data email.NotificationData) error

SendNewRecommendationsNotification mocks the SendNewRecommendationsNotification operation.

func (*MockEmailSender) SendNotification

func (m *MockEmailSender) SendNotification(ctx context.Context, subject, message string) error

SendNotification mocks the SendNotification operation.

func (*MockEmailSender) SendPasswordResetEmail

func (m *MockEmailSender) SendPasswordResetEmail(ctx context.Context, emailAddr, resetURL string) error

SendPasswordResetEmail mocks the SendPasswordResetEmail operation.

func (*MockEmailSender) SendPurchaseApprovalRequest

func (m *MockEmailSender) SendPurchaseApprovalRequest(ctx context.Context, data email.NotificationData) error

SendPurchaseApprovalRequest mocks the SendPurchaseApprovalRequest operation.

func (*MockEmailSender) SendPurchaseConfirmation

func (m *MockEmailSender) SendPurchaseConfirmation(ctx context.Context, data email.NotificationData) error

SendPurchaseConfirmation mocks the SendPurchaseConfirmation operation.

func (*MockEmailSender) SendPurchaseExecutedNotification

func (m *MockEmailSender) SendPurchaseExecutedNotification(ctx context.Context, data email.NotificationData) error

SendPurchaseExecutedNotification mocks the post-execution notification operation (issue #291).

func (*MockEmailSender) SendPurchaseFailedNotification

func (m *MockEmailSender) SendPurchaseFailedNotification(ctx context.Context, data email.NotificationData) error

SendPurchaseFailedNotification mocks the SendPurchaseFailedNotification operation.

func (*MockEmailSender) SendRegistrationDecisionNotification

func (m *MockEmailSender) SendRegistrationDecisionNotification(ctx context.Context, toEmail string, data email.RegistrationDecisionData) error

func (*MockEmailSender) SendRegistrationReceivedNotification

func (m *MockEmailSender) SendRegistrationReceivedNotification(ctx context.Context, data email.RegistrationNotificationData) error

func (*MockEmailSender) SendScheduledPurchaseNotification

func (m *MockEmailSender) SendScheduledPurchaseNotification(ctx context.Context, data email.NotificationData) error

SendScheduledPurchaseNotification mocks the SendScheduledPurchaseNotification operation.

func (*MockEmailSender) SendToEmail

func (m *MockEmailSender) SendToEmail(ctx context.Context, toEmail, subject, body string) error

SendToEmail mocks the SendToEmail operation.

func (*MockEmailSender) SendWelcomeEmail

func (m *MockEmailSender) SendWelcomeEmail(ctx context.Context, emailAddr, dashboardURL, role string) error

SendWelcomeEmail mocks the SendWelcomeEmail operation.

type MockSESClient

type MockSESClient struct {
	mock.Mock
}

MockSESClient is a mock implementation of SES client.

func (*MockSESClient) SendEmail

func (m *MockSESClient) SendEmail(ctx context.Context, input *sesv2.SendEmailInput, opts ...func(*sesv2.Options)) (*sesv2.SendEmailOutput, error)

SendEmail mocks the SendEmail operation.

type MockSNSClient

type MockSNSClient struct {
	mock.Mock
}

MockSNSClient is a mock implementation of SNS client.

func (*MockSNSClient) Publish

func (m *MockSNSClient) Publish(ctx context.Context, input *sns.PublishInput, opts ...func(*sns.Options)) (*sns.PublishOutput, error)

Publish mocks the Publish operation.

type MockSecretsManagerClient

type MockSecretsManagerClient struct {
	mock.Mock
}

MockSecretsManagerClient is a mock implementation of Secrets Manager client.

func (*MockSecretsManagerClient) CreateSecret

CreateSecret mocks the CreateSecret operation.

func (*MockSecretsManagerClient) GetSecretValue

GetSecretValue mocks the GetSecretValue operation.

func (*MockSecretsManagerClient) UpdateSecret

UpdateSecret mocks the UpdateSecret operation.

type SESAPI

type SESAPI interface {
	SendEmail(ctx context.Context, input *sesv2.SendEmailInput, opts ...func(*sesv2.Options)) (*sesv2.SendEmailOutput, error)
}

SESAPI defines the interface for SES operations used by our code.

type SNSAPI

type SNSAPI interface {
	Publish(ctx context.Context, input *sns.PublishInput, opts ...func(*sns.Options)) (*sns.PublishOutput, error)
}

SNSAPI defines the interface for SNS operations used by our code.

type SecretsManagerAPI

SecretsManagerAPI defines the interface for Secrets Manager operations used by our code.

Jump to

Keyboard shortcuts

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