Documentation ¶
Overview ¶
Package testonly contains an Election implementation for testing.
Index ¶
- Variables
- type Decorator
- func (d *Decorator) Await(ctx context.Context) error
- func (d *Decorator) BlockAwait(block bool)
- func (d *Decorator) Close(ctx context.Context) error
- func (d *Decorator) Resign(ctx context.Context) error
- func (d *Decorator) Update(errs Errs)
- func (d *Decorator) WithMastership(ctx context.Context) (context.Context, error)
- type Election
- type Errs
- type NamedTest
Constants ¶
This section is empty.
Variables ¶
var Factory factory
Factory allows creating Election instances for testing.
var Tests = []NamedTest{
{Name: "RunElectionAwait", Run: runElectionAwait},
{Name: "RunElectionWithMastership", Run: runElectionWithMastership},
{Name: "RunElectionResign", Run: runElectionResign},
{Name: "RunElectionClose", Run: runElectionClose},
{Name: "RunElectionLoop", Run: runElectionLoop},
}
Tests is the full list of available Election tests. TODO(pavelkalinnikov): Add tests for unexpected mastership loss.
Functions ¶
This section is empty.
Types ¶
type Decorator ¶
type Decorator struct {
// contains filtered or unexported fields
}
Decorator is an election2.Election decorator injecting errors, for testing.
func NewDecorator ¶
NewDecorator returns a Decorator wrapping the passed in Election object.
func (*Decorator) BlockAwait ¶
BlockAwait enables or disables Await method blocking.
type Election ¶
type Election struct {
// contains filtered or unexported fields
}
Election implements election2.Election interface for testing.
func NewElection ¶
func NewElection() *Election
NewElection returns a new initialized Election for testing.
func (*Election) Await ¶
Await sets this instance to be the master. It always succeeds. To imitate errors and/or blocking behavior use the Decorator type.