test

package
v1.2.11 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ProjectRoot

func ProjectRoot(t *testing.T) string

ProjectRoot is a utility function for returning root path of the networker source code on this machine. It's primary purpose is to help construct absolute paths needed by tests.

func WithMockServer

func WithMockServer(t *testing.T, fn RequestFunc)

WithMockServer is a pre-test hook that starts the pre-configured mock server and passes it's URL to to the down stream test. It also handles teardown of the server and ensures the underlying test is parallelized.

func WithNetworker

func WithNetworker(t *testing.T, name string, fn func(t *testing.T))

WithNetworker is a pre-test hook that asserts the networker binary is globally installed before running the test. It's intended to be used in the cmd/networker pkg.

Types

type MockObject

type MockObject struct {
	ID    int    `json:"id,omitempty"`
	Field string `json:"field"`
}

MockObject is an arbitrary object that can be encoded/decoded and it's primary function is to provide a shape for the mock web server to use for its transport and store layers.

type RequestFunc

type RequestFunc func(t *testing.T, serverURL string)

RequestFunc is the method signature the WithMockServer hook expects.

Jump to

Keyboard shortcuts

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