starrtest

package
v0.0.0-...-fc20fab Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package starrtest provides methods that are shared by all the tests in the other sub packages.

Index

Constants

View Source
const (
	// Error body for 401 response.
	BodyUnauthorized = `{"error": "Unauthorized"}`
	// Error body for 404 response.
	BodyNotFound = `{"message": "NotFound"}`
	// Error body for 405 response.
	BodyMethodNotAllowed = `{"message": "MethodNotAllowed"}`
)

Variables

This section is empty.

Functions

This section is empty.

Types

type MockData

type MockData struct {
	// A name for the test.
	Name string
	// The path expected in the request ie. /api/v1/thing
	ExpectedPath string
	// The request body (json) expected from the caller.
	ExpectedRequest string
	// The request method (GET/POST) expected from the caller.
	ExpectedMethod string
	// This is the status that gets returned the caller.
	ResponseStatus int
	// The (json) response body returned to caller.
	ResponseBody string
	// Caller's request.
	WithRequest interface{}
	// Caller's response.
	WithResponse interface{}
	// Caller's response.
	WithError error
}

MockData allows generic testing of http inputs and outputs. This is used by the submodule tests.

func (*MockData) GetMockServer

func (test *MockData) GetMockServer(t *testing.T) *httptest.Server

GetMockServer is used in all the submodule http tests.

Jump to

Keyboard shortcuts

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