Help us shape the future of Go! Take the 2026 Go Developer Survey

crontest

package
v0.19.0 Latest Latest
Warning

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

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

Documentation

Overview

Package crontest holds the cases every cron job store passes and an in-memory store that passes them.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(t *testing.T, fresh Factory)

Run runs every case against fresh stores from fresh, each in parallel.

Types

type Case

type Case struct {
	Name string
	Run  func(t *testing.T, s Stores)
}

Case is one named check every cron job store passes.

func Cases

func Cases() []Case

Cases returns every check a cron job store passes.

type Factory

type Factory func(t *testing.T) Stores

Factory returns fresh stores for one case.

type MemoryStore

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

MemoryStore keeps cron jobs and their leases in memory.

func NewMemoryStore

func NewMemoryStore() *MemoryStore

NewMemoryStore returns an empty in-memory cron job store.

func (*MemoryStore) LastFailure

func (m *MemoryStore) LastFailure(_ context.Context, name string) (string, error)

LastFailure returns the failure the job's last run recorded, empty when it ran well.

func (*MemoryStore) Settle

func (m *MemoryStore) Settle(_ context.Context, lease cron.Lease, outcome cron.Outcome) error

Settle frees the job and records how its run ended, refusing a lease another run took over.

func (*MemoryStore) Slots

func (m *MemoryStore) Slots(context.Context) ([]cron.Slot, error)

Slots returns where every stored job stands.

func (*MemoryStore) Take

func (m *MemoryStore) Take(_ context.Context, lease cron.Lease) (cron.Lease, bool, error)

Take claims the job for the lease when it is due and free, reporting whether it did.

type Stores

type Stores struct {
	Store       cron.Store
	LastFailure func(ctx context.Context, name string) (string, error)
}

Stores is one fresh store under test and a way to read the failure its last run recorded.

Jump to

Keyboard shortcuts

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