testutil

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package testutil holds helpers shared by tests.

Index

Constants

This section is empty.

Variables

View Source
var ErrInjected = errors.New("fakestore: injected failure")

Functions

func Eventually

func Eventually(tb testing.TB, cond func() bool, timeout time.Duration, msgAndArgs ...any)

Eventually polls cond until it returns true or timeout elapses.

Types

type FakeStore

type FakeStore struct {
	FetchHook func(rows []*job.Row)
	// contains filtered or unexported fields
}

FakeStore is an in-memory job store with the same semantics as the Postgres adapter.

func NewFakeStore

func NewFakeStore() *FakeStore

NewFakeStore returns an empty store.

func (*FakeStore) AcquireLease

func (s *FakeStore) AcquireLease(_ context.Context, _, id string, now time.Time, ttl time.Duration) (bool, error)

func (*FakeStore) CancelRequested

func (s *FakeStore) CancelRequested(_ context.Context, ids []int64) ([]int64, error)

func (*FakeStore) Complete

func (s *FakeStore) Complete(_ context.Context, clientID string, cs []job.Completion) ([]int64, error)

func (*FakeStore) DeleteFinalized

func (s *FakeStore) DeleteFinalized(_ context.Context, state job.State, cutoff time.Time, limit int) (int, error)

func (*FakeStore) EnqueueTick

func (s *FakeStore) EnqueueTick(_ context.Context, name string, tick time.Time, p job.InsertParams) (bool, error)

func (*FakeStore) FailNext

func (s *FakeStore) FailNext(n int)

func (*FakeStore) Fetch

func (s *FakeStore) Fetch(_ context.Context, p job.FetchParams) ([]*job.Row, error)

func (*FakeStore) Heartbeat

func (s *FakeStore) Heartbeat(_ context.Context, clientID string, now time.Time, refs []job.Ref) (int, error)

func (*FakeStore) Insert

func (s *FakeStore) Insert(p job.InsertParams) int64

func (*FakeStore) Job

func (s *FakeStore) Job(id int64) (job.Row, bool)

func (*FakeStore) Jobs

func (s *FakeStore) Jobs() []job.Row

func (*FakeStore) KeyStats

func (s *FakeStore) KeyStats(_ context.Context, queue string, limit int, _ bool) ([]job.KeyStat, error)

func (*FakeStore) LastTicks

func (s *FakeStore) LastTicks(context.Context) (map[string]time.Time, error)

func (*FakeStore) LeaseHolder

func (s *FakeStore) LeaseHolder() (string, time.Time)

func (*FakeStore) MarkPeriodicStart

func (s *FakeStore) MarkPeriodicStart(_ context.Context, name string, now time.Time) error

func (*FakeStore) PromoteDue

func (s *FakeStore) PromoteDue(_ context.Context, now time.Time, limit int) (int, error)

func (*FakeStore) PruneTicks

func (s *FakeStore) PruneTicks(_ context.Context, cutoff time.Time) (int, error)

func (*FakeStore) QueueDepths

func (s *FakeStore) QueueDepths(context.Context) ([]job.QueueDepth, error)

func (*FakeStore) QueueHeartbeat

func (s *FakeStore) QueueHeartbeat(_ context.Context, queue string, _ time.Time) (bool, error)

func (*FakeStore) Reindex

func (s *FakeStore) Reindex(context.Context) (bool, error)

func (*FakeStore) ReleaseLease

func (s *FakeStore) ReleaseLease(_ context.Context, _, id string) error

func (*FakeStore) RenewLease

func (s *FakeStore) RenewLease(_ context.Context, _, id string, now time.Time, ttl time.Duration) (bool, error)

func (*FakeStore) Rescue

func (s *FakeStore) Rescue(_ context.Context, cutoff time.Time, cs []job.Completion) (int, error)

func (*FakeStore) RunningByKey

func (s *FakeStore) RunningByKey(queue string) map[string]int

func (*FakeStore) SetPaused

func (s *FakeStore) SetPaused(queue string, paused bool)

func (*FakeStore) StuckJobs

func (s *FakeStore) StuckJobs(_ context.Context, cutoff time.Time, limit int) ([]*job.Row, error)

func (*FakeStore) Ticks

func (s *FakeStore) Ticks(name string) []time.Time

func (*FakeStore) Update

func (s *FakeStore) Update(id int64, fn func(*job.Row))

Directories

Path Synopsis
Package pgtest provides Postgres for integration tests.
Package pgtest provides Postgres for integration tests.

Jump to

Keyboard shortcuts

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