forwardtest

package
v0.41.4 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package forwardtest holds the fakes the forwarder's tests inject: a lease view, a runner that records its calls, and a Redis clock that a test can set apart from the wall clock.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Call

type Call struct {
	Kind        forward.Kind
	User, Group string
	Args        any
}

Call is one recorded Runner call.

type Clock

type Clock struct {
	Err error
	// contains filtered or unexported fields
}

Clock is a Redis clock a test sets.

func NewClock

func NewClock(ms int64) *Clock

NewClock starts at ms.

func (*Clock) Advance

func (c *Clock) Advance(d time.Duration)

Advance moves the clock.

func (*Clock) RedisTimeMS

func (c *Clock) RedisTimeMS(context.Context) (int64, error)

type LeaseView

type LeaseView struct {
	Owners   map[string]forward.LeaseOwner
	HeldAt   map[string]int64
	Past     bool
	OwnerErr error
	// contains filtered or unexported fields
}

LeaseView is a settable forward.LeaseView.

func (*LeaseView) DeleteOwner

func (l *LeaseView) DeleteOwner(group string)

func (*LeaseView) Forget

func (l *LeaseView) Forget(string)

Forget is a no-op (the fake caches nothing); it lets the fake stand in for a caching view.

func (*LeaseView) Held

func (l *LeaseView) Held(group string) (int64, bool)

func (*LeaseView) Owner

func (l *LeaseView) Owner(_ context.Context, group string) (forward.LeaseOwner, error)

func (*LeaseView) PastDeadline

func (l *LeaseView) PastDeadline() bool

func (*LeaseView) SetOwner

func (l *LeaseView) SetOwner(group string, o forward.LeaseOwner)

SetOwner sets the lease row a group shows; DeleteOwner removes it; SetPast sets the local deadline verdict. They are safe to call while an Owner reads the view.

func (*LeaseView) SetPast

func (l *LeaseView) SetPast(p bool)

type Runner

type Runner struct {
	Reply forward.Result
	Err   error
	// contains filtered or unexported fields
}

Runner records its calls and answers with Reply (200 and an empty object by default) or Err.

func (*Runner) Calls

func (r *Runner) Calls() []Call

Calls returns a copy of the recorded calls.

func (*Runner) Run

func (r *Runner) Run(_ context.Context, kind forward.Kind, user, group string, args any) (forward.Result, error)

Jump to

Keyboard shortcuts

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