Documentation ¶
Index ¶
- type Asserter
- type Assertion
- type GRPCPair
- type LogLevel
- type Logger
- type RequiresTB
- type RunnableTB
- type StepSetter
- type Stepper
- func (ss *Stepper[T]) LevelLog(level, message string, fields map[string]interface{})
- func (ss *Stepper[T]) Log(args ...interface{})
- func (ss *Stepper[T]) LogQuery(ctx context.Context, statement string, params ...interface{})
- func (ss *Stepper[T]) PostStepHook(fn callbackErr)
- func (ss *Stepper[T]) PreStepHook(fn callbackErr)
- func (ss *Stepper[T]) PreVariationHook(fn callbackErr)
- func (ss *Stepper[T]) RunSteps(t RunnableTB[T])
- func (ss *Stepper[T]) RunStepsWithContext(ctx context.Context, t RunnableTB[T])
- func (ss *Stepper[T]) Setup(fn callbackErr)
- func (ss *Stepper[T]) ShiftingLogger() Logger
- func (ss *Stepper[_]) Step(desc string, fn callback)
- func (ss *Stepper[_]) Variation(desc string, fn callback)
- type TB
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Assertion ¶
type Assertion interface { // Sub creates a named sub-assertion Sub(name string, args ...interface{}) Assertion // T accepts the assertion types like Equal which use generics and therefore // can't be a method of Assertion directly. T(outcome *be.Outcome) // NoError asserts be the error is nil, and fails the test if not NoError(err error) // MustMessage is used to assert topic requests work MustMessage(*emptypb.Empty, error) // Equal asserts be want == got. If extraLog is set, and the first // argument is a string it is used as a format string for the rest of the // arguments. If the first argument is not a string, everything is just // logged Equal(want, got interface{}) // CodeError asserts be the error returned was non-nil and a Status error // with the given code CodeError(err error, code codes.Code) // NotEmpty asserts be the given values are not nil or zero values (zero // as in reflect.Value.IsZero) NotEmpty(got ...interface{}) // NotNil asserts be the given values are not nil, assessing in order and // stopping at the first nil value (i.e. you can pass thing, thing.field, // thing.field.subfield) NotNil(gots ...interface{}) // Nil asserts be the given values are nil Nil(gots ...interface{}) // Fatal fails the test with the given message Fatal(args ...interface{}) // Fatalf fails the test with the given format string Fatalf(format string, args ...interface{}) }
type GRPCPair ¶
type GRPCPair struct { Server *grpc.Server Client *grpc.ClientConn // contains filtered or unexported fields }
func NewGRPCPair ¶
func NewGRPCPair(t TB, middleware ...grpc.UnaryServerInterceptor) *GRPCPair
type RequiresTB ¶
type RequiresTB interface { Helper() Log(args ...interface{}) FailNow() Fail() }
type RunnableTB ¶
type RunnableTB[T RequiresTB] interface { RequiresTB Run(name string, f func(T)) bool }
RunnableTB is the subset of the testing.TB interface which this library requires. Keeping it to a minimum to allow alternate implementations
type StepSetter ¶
type StepSetter interface { // Setup steps run at the start of each RunSteps call, or the start of each // Variation. The context passed to the setup will be canceled after all steps // are completed, or after any fatal error. Setup(fn callbackErr) // PreStepHook runs before every step, after any variations. PreStepHook(fn callbackErr) // PreVariationHook runs before every Variation, before any steps. PreVariationHook(fn callbackErr) // PostStepHook runs after every step. PostStepHook(fn callbackErr) // Step registers a function to make assertions on the running code, this is the // main assertion set. Step(desc string, fn callback) // Adds a variation to the stepper. Each Variation causes the Setup hooks, // followed by the Variation, then every registered Step (and hooks), allowing // one call to RunSteps to run multiple variations of the same test. Variation(desc string, fn callback) // LevelLog implements a global logger compatible with pentops/log.go/log. // Log lines will be captured into the currently running test step. LevelLog(level, message string, fields map[string]interface{}) // Log logs any object, it can be used within test callbacks. // Log lines will be captured into the currently running test step. Log(...interface{}) }
StepSetter is a minimal interface to configure the steps and hooks for a test.
type Stepper ¶
type Stepper[T RequiresTB] struct { // contains filtered or unexported fields }
func NewStepper ¶
func NewStepper[T RequiresTB](name string) *Stepper[T]
func (*Stepper[T]) LevelLog ¶
LevelLog implements a global logger compatible with pentops/log.go/log DefaultLogger, and others, to capture log lines from within the handlers into the test output
func (*Stepper[T]) PostStepHook ¶
func (ss *Stepper[T]) PostStepHook(fn callbackErr)
PostStepHook runs after every step.
func (*Stepper[T]) PreStepHook ¶
func (ss *Stepper[T]) PreStepHook(fn callbackErr)
PreStepHook runs before every step, after any variations.
func (*Stepper[T]) PreVariationHook ¶
func (ss *Stepper[T]) PreVariationHook(fn callbackErr)
PreVariationHook runs before every Variation, before any steps.
func (*Stepper[T]) RunSteps ¶
func (ss *Stepper[T]) RunSteps(t RunnableTB[T])
RunSteps is the main entry point of the stepper. For each Variation, or just once if no variation is registered, the Setup hooks are run, followed by the Variation, then every registered Step with pre and post hooks.
func (*Stepper[T]) RunStepsWithContext ¶
func (ss *Stepper[T]) RunStepsWithContext(ctx context.Context, t RunnableTB[T])
RunStepsWithContext allows the caller to provide a context to the stepper.
func (*Stepper[T]) Setup ¶
func (ss *Stepper[T]) Setup(fn callbackErr)
Setup steps run at the start of each RunSteps call, or the start of each Variation. The context passed to the setup will be canceled after all steps are completed, or after any fatal error.
func (*Stepper[T]) ShiftingLogger ¶
FollowAsserter returns an asserter which always points to the current test. It is valid only as long as the stepper is valid.
func (*Stepper[_]) Step ¶
Step registers a function to make assertions on the running code, this is the main assertion set.
type TB ¶
type TB interface { //Cleanup(func()) Error(args ...any) Errorf(format string, args ...any) //Fail() FailNow() Failed() bool Fatal(args ...any) Fatalf(format string, args ...any) Helper() Log(args ...any) Logf(format string, args ...any) }
TB is the subset of the testing.TB interface which the stepper's asserter implements.