testutils

package
v0.0.0-...-84339fa Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 14 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 NewFiberCaller

func NewFiberCaller(t testing.TB, callerID string) fiber.Component

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

func NewHTTPFiberRequest

func NewHTTPFiberRequest(t testing.TB, header http.Header, body string) fiber.Request

NewHTTPFiberRequest create new http fiber request based on header and body

func NewUPIFiberRequest

func NewUPIFiberRequest(t testing.TB, header map[string]string, request *upiv1.PredictValuesRequest) fiber.Request

NewUPIFiberRequest create new grpc fiber request based on header and upi request

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.

func (MockExperimentRunner) RegisterMetricsCollector

func (mp MockExperimentRunner) RegisterMetricsCollector(
	_ metrics.Collector,
	_ runner.MetricsRegistrationHelper,
) error

Jump to

Keyboard shortcuts

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