testutil

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MockClient

func MockClient(
	t *testing.T,
	fixture ResponseData,
	output *RequestData,
	callback HTTPHandler) (*platform.Client, *httptest.Server)

MockClient returns a client to mock HTTP requests with a callback function

Types

type HTTPHandler

type HTTPHandler func(w http.ResponseWriter, r *http.Request)

HTTPHandler type defines callback from doing a mock HTTP request

type RequestData

type RequestData struct {
	URL    url.URL
	Body   []byte
	Method string
	JSON   string
}

RequestData holds test HTTP request data

type ResponseData added in v1.0.0

type ResponseData struct {
	Body       string
	StatusCode int
}

func Fixture

func Fixture(path string, statusCode int) ResponseData

Fixture loads a fixture file to a string

Jump to

Keyboard shortcuts

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