testutil

package
v0.0.0-...-a99bcb5 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: OSL-3.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package testutil provides common utilities for testing

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertContains

func AssertContains(t *testing.T, str, substr string)

AssertContains fails the test if substr is not in str.

func AssertEqual

func AssertEqual(t *testing.T, expected, actual any)

AssertEqual fails the test if expected != actual.

func AssertError

func AssertError(t *testing.T, err error)

AssertError fails the test if err is nil.

func AssertFalse

func AssertFalse(t *testing.T, condition bool, message string)

AssertFalse fails the test if condition is true.

func AssertNoError

func AssertNoError(t *testing.T, err error)

AssertNoError fails the test if err is not nil.

func AssertNotContains

func AssertNotContains(t *testing.T, str, substr string)

AssertNotContains fails the test if substr is in str.

func AssertNotEqual

func AssertNotEqual(t *testing.T, expected, actual any)

AssertNotEqual fails the test if expected == actual.

func AssertTrue

func AssertTrue(t *testing.T, condition bool, message string)

AssertTrue fails the test if condition is false.

func RequireEnv

func RequireEnv(t *testing.T, key string) string

RequireEnv skips the test if the environment variable is not set.

func SetEnv

func SetEnv(t *testing.T, key, value string)

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 SkipCI

func SkipCI(t *testing.T)

SkipCI skips the test if running in CI environment.

func SkipIfShort

func SkipIfShort(t *testing.T)

SkipIfShort skips the test if running in short mode.

func TestContext

func TestContext(t *testing.T) context.Context

TestContext creates a context with a reasonable timeout for tests.

func WaitFor

func WaitFor(t *testing.T, condition func() bool, timeout time.Duration, message string)

WaitFor waits for a condition to be true, checking every interval.

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).

Jump to

Keyboard shortcuts

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