test

package
v0.0.0-...-5dd6c5c Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package test provides test utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMockAPI

func NewMockAPI(t *testing.T, responses Routes) *httptest.Server

NewMockAPI starts a httptest server which responds to any request with the given response.

Types

type AssertionFunc

type AssertionFunc func(t *testing.T, r *http.Request)

AssertionFunc allows to write assertions about the request to ensure the request has been sent correctly.

type Response

type Response struct {
	StatusCode int
	FileName   string
	Headers    map[string]string
	Assertion  AssertionFunc
}

Response contains a response the testserver responds with

func NewResponse

func NewResponse(statusCode int, fileName string) Response

NewResponse creates a response.

type Routes

type Routes map[string]Response

Routes is a map whose key is method + path. If that matches, the assigned response is returned

Jump to

Keyboard shortcuts

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