Documentation
¶
Overview ¶
Package testutil provides common utilities for testing
Index ¶
- func AssertContains(t *testing.T, str, substr string)
- func AssertEqual(t *testing.T, expected, actual any)
- func AssertError(t *testing.T, err error)
- func AssertFalse(t *testing.T, condition bool, message string)
- func AssertNoError(t *testing.T, err error)
- func AssertNotContains(t *testing.T, str, substr string)
- func AssertNotEqual(t *testing.T, expected, actual any)
- func AssertTrue(t *testing.T, condition bool, message string)
- func RequireEnv(t *testing.T, key string) string
- func SetEnv(t *testing.T, key, value string)
- func SkipCI(t *testing.T)
- func SkipIfShort(t *testing.T)
- func TestContext(t *testing.T) context.Context
- func WaitFor(t *testing.T, condition func() bool, timeout time.Duration, message string)
- type MockPurchaseManager
- func (m *MockPurchaseManager) ApproveAndExecute(ctx context.Context, execID, actor string, transitionedBy *string, ...) (*config.PurchaseExecution, string, error)
- func (m *MockPurchaseManager) ApproveExecution(ctx context.Context, execID, token, actor string, ...) (*config.PurchaseExecution, string, error)
- func (m *MockPurchaseManager) CancelExecution(ctx context.Context, execID, token, actor string) error
- func (m *MockPurchaseManager) DirectExecute(ctx context.Context, execID, actor string, transitionedBy *string, ...) (*config.PurchaseExecution, string, error)
- func (m *MockPurchaseManager) FinalizeInFlightRevocations(ctx context.Context) (*purchase.FinalizeResult, error)
- func (m *MockPurchaseManager) FireScheduledDelayedPurchases(ctx context.Context) (*purchase.FireResult, error)
- func (m *MockPurchaseManager) ProcessScheduledPurchases(ctx context.Context) (*purchase.ProcessResult, error)
- func (m *MockPurchaseManager) ReapStuckExecutions(ctx context.Context, reapAfter time.Duration) (*purchase.ReapResult, error)
- func (m *MockPurchaseManager) RunPlannedPurchaseNow(ctx context.Context, execID, actor string, transitionedBy *string, ...) (*config.PurchaseExecution, string, error)
- func (m *MockPurchaseManager) SendUpcomingPurchaseNotifications(ctx context.Context) (*purchase.NotificationResult, error)
- type MockScheduler
- func (m *MockScheduler) CollectRecommendations(ctx context.Context, ownerToken string) (*scheduler.CollectResult, error)
- func (m *MockScheduler) GetRecommendationByID(ctx context.Context, id string) (*config.RecommendationRecord, []string, error)
- func (m *MockScheduler) ListRecommendations(ctx context.Context, filter config.RecommendationFilter) ([]config.RecommendationRecord, error)
- func (m *MockScheduler) ListRecommendationsStrict(ctx context.Context, filter config.RecommendationFilter) ([]config.RecommendationRecord, error)
- func (m *MockScheduler) PageRecommendations(ctx context.Context, scope config.RecommendationListScope, afterID string, ...) (*config.RecommendationPage, error)
- func (m *MockScheduler) ScanRecommendations(ctx context.Context, filter config.RecommendationFilter, chunkSize int, ...) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertContains ¶
AssertContains fails the test if substr is not in str.
func AssertEqual ¶
AssertEqual fails the test if expected != actual.
func AssertError ¶
AssertError fails the test if err is nil.
func AssertFalse ¶
AssertFalse fails the test if condition is true.
func AssertNoError ¶
AssertNoError fails the test if err is not nil.
func AssertNotContains ¶
AssertNotContains fails the test if substr is in str.
func AssertNotEqual ¶
AssertNotEqual fails the test if expected == actual.
func AssertTrue ¶
AssertTrue fails the test if condition is false.
func RequireEnv ¶
RequireEnv skips the test if the environment variable is not set.
func SetEnv ¶
SetEnv sets an environment variable for the duration of the test and restores the exact prior state (including the distinction between an unset variable and a variable set to "") on cleanup.
func SkipIfShort ¶
SkipIfShort skips the test if running in short mode.
func TestContext ¶
TestContext creates a context with a reasonable timeout for tests.
Types ¶
type MockPurchaseManager ¶
type MockPurchaseManager struct {
ProcessScheduledPurchasesFunc func(ctx context.Context) (*purchase.ProcessResult, error)
SendUpcomingPurchaseNotificationsFunc func(ctx context.Context) (*purchase.NotificationResult, error)
ApproveExecutionFunc func(ctx context.Context, execID, token, actor string, check purchase.ClaimedRowCheck) (*config.PurchaseExecution, string, error)
ApproveAndExecuteFunc func(ctx context.Context, execID, actor string, transitionedBy *string, check purchase.ClaimedRowCheck) (*config.PurchaseExecution, string, error)
DirectExecuteFunc func(ctx context.Context, execID, actor string, transitionedBy *string, check purchase.ClaimedRowCheck) (*config.PurchaseExecution, string, error)
RunPlannedPurchaseNowFunc func(ctx context.Context, execID, actor string, transitionedBy *string, check purchase.ClaimedRowCheck) (*config.PurchaseExecution, string, error)
CancelExecutionFunc func(ctx context.Context, execID, token, actor string) error
ReapStuckExecutionsFunc func(ctx context.Context, reapAfter time.Duration) (*purchase.ReapResult, error)
FireScheduledDelayedPurchasesFunc func(ctx context.Context) (*purchase.FireResult, error)
FinalizeInFlightRevocationsFunc func(ctx context.Context) (*purchase.FinalizeResult, error)
}
MockPurchaseManager is a mock implementation of server.PurchaseManagerInterface.
func (*MockPurchaseManager) ApproveAndExecute ¶
func (m *MockPurchaseManager) ApproveAndExecute(ctx context.Context, execID, actor string, transitionedBy *string, check purchase.ClaimedRowCheck) (*config.PurchaseExecution, string, error)
func (*MockPurchaseManager) ApproveExecution ¶
func (m *MockPurchaseManager) ApproveExecution(ctx context.Context, execID, token, actor string, check purchase.ClaimedRowCheck) (*config.PurchaseExecution, string, error)
func (*MockPurchaseManager) CancelExecution ¶
func (m *MockPurchaseManager) CancelExecution(ctx context.Context, execID, token, actor string) error
func (*MockPurchaseManager) DirectExecute ¶
func (m *MockPurchaseManager) DirectExecute(ctx context.Context, execID, actor string, transitionedBy *string, check purchase.ClaimedRowCheck) (*config.PurchaseExecution, string, error)
func (*MockPurchaseManager) FinalizeInFlightRevocations ¶
func (m *MockPurchaseManager) FinalizeInFlightRevocations(ctx context.Context) (*purchase.FinalizeResult, error)
func (*MockPurchaseManager) FireScheduledDelayedPurchases ¶
func (m *MockPurchaseManager) FireScheduledDelayedPurchases(ctx context.Context) (*purchase.FireResult, error)
func (*MockPurchaseManager) ProcessScheduledPurchases ¶
func (m *MockPurchaseManager) ProcessScheduledPurchases(ctx context.Context) (*purchase.ProcessResult, error)
func (*MockPurchaseManager) ReapStuckExecutions ¶
func (m *MockPurchaseManager) ReapStuckExecutions(ctx context.Context, reapAfter time.Duration) (*purchase.ReapResult, error)
func (*MockPurchaseManager) RunPlannedPurchaseNow ¶
func (m *MockPurchaseManager) RunPlannedPurchaseNow(ctx context.Context, execID, actor string, transitionedBy *string, check purchase.ClaimedRowCheck) (*config.PurchaseExecution, string, error)
func (*MockPurchaseManager) SendUpcomingPurchaseNotifications ¶
func (m *MockPurchaseManager) SendUpcomingPurchaseNotifications(ctx context.Context) (*purchase.NotificationResult, error)
type MockScheduler ¶
type MockScheduler struct {
CollectRecommendationsFunc func(ctx context.Context, ownerToken string) (*scheduler.CollectResult, error)
ListRecommendationsFunc func(ctx context.Context, filter config.RecommendationFilter) ([]config.RecommendationRecord, error)
GetRecommendationByIDFunc func(ctx context.Context, id string) (*config.RecommendationRecord, []string, error)
ListRecommendationsStrictFunc func(ctx context.Context, filter config.RecommendationFilter) ([]config.RecommendationRecord, error)
ScanRecommendationsFunc func(ctx context.Context, filter config.RecommendationFilter, chunkSize int, fn func([]config.RecommendationRecord) error) error
PageRecommendationsFunc func(ctx context.Context, scope config.RecommendationListScope, afterID string, limit int) (*config.RecommendationPage, error)
}
MockScheduler is a mock implementation of server.SchedulerInterface.
func (*MockScheduler) CollectRecommendations ¶
func (m *MockScheduler) CollectRecommendations(ctx context.Context, ownerToken string) (*scheduler.CollectResult, error)
func (*MockScheduler) GetRecommendationByID ¶
func (m *MockScheduler) GetRecommendationByID(ctx context.Context, id string) (*config.RecommendationRecord, []string, error)
func (*MockScheduler) ListRecommendations ¶
func (m *MockScheduler) ListRecommendations(ctx context.Context, filter config.RecommendationFilter) ([]config.RecommendationRecord, error)
func (*MockScheduler) ListRecommendationsStrict ¶
func (m *MockScheduler) ListRecommendationsStrict(ctx context.Context, filter config.RecommendationFilter) ([]config.RecommendationRecord, error)
ListRecommendationsStrict defaults to an empty read.
func (*MockScheduler) PageRecommendations ¶
func (m *MockScheduler) PageRecommendations(ctx context.Context, scope config.RecommendationListScope, afterID string, limit int) (*config.RecommendationPage, error)
PageRecommendations defaults to sending the caller to the scan, so a test that only sets ScanRecommendationsFunc keeps driving the paginated list.
func (*MockScheduler) ScanRecommendations ¶
func (m *MockScheduler) ScanRecommendations(ctx context.Context, filter config.RecommendationFilter, chunkSize int, fn func([]config.RecommendationRecord) error) error
ScanRecommendations defaults to an empty cache: fn is never called.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package goroutines lets tests wait on, or rule out, background goroutines without a wall-clock sleep (#36).
|
Package goroutines lets tests wait on, or rule out, background goroutines without a wall-clock sleep (#36). |
|
Package lambdatimeout pins the AWS Lambda timeouts the repository ships against the Go budgets for work detached from the request (#913).
|
Package lambdatimeout pins the AWS Lambda timeouts the repository ships against the Go budgets for work detached from the request (#913). |