testutils

package
v0.0.0-...-20989ac Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package testutils contains mocks that can be shared across tests for multiple packages

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFiberCallerWithHTTPDispatcher

func NewFiberCallerWithHTTPDispatcher(t *testing.T, callerID string) fiber.Component

NewFiberCallerWithHTTPDispatcher is a helper function to create an instance of Fiber caller in the test cases so the test cases are easier to read.

Types

type MockExperimentRunner

type MockExperimentRunner struct {
	*runner.Treatment
	// If WantErr is true, GetTreatmentForRequest() will return a non-nil error
	WantErr bool
	// If WantTimeout is true, GetTreatmentForRequest() will wait for the duration of
	// Timeout and return a non-nil error
	WantTimeout bool
	// Timeout to wait for
	Timeout time.Duration
}

MockExperimentRunner is a mock implementation for the Planner interface

func (MockExperimentRunner) GetTreatmentForRequest

func (mp MockExperimentRunner) GetTreatmentForRequest(
	http.Header,
	[]byte,
	runner.GetTreatmentOptions,
) (*runner.Treatment, error)

GetTreatmentForRequest returns the experiment treatment provided when MockExperimentRunner is initialized with TestTreatment. If MockExperimentRunner.WantErr is true, GetTreatmentForRequest will return error.

Jump to

Keyboard shortcuts

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