spectest

package module
v0.0.18 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2023 License: MIT Imports: 35 Imported by: 0

README

Go Reference LinuxUnitTest MacUnitTest WindowsUnitTest UnitTestExampleCodes reviewdog Gosec Coverage

What is spectest?

A simple and extensible behavioral testing library. Supports mocking external http calls and renders sequence diagrams on completion. In behavioral tests the internal structure of the app is not known by the tests. Data is input to the system and the outputs are expected to meet certain conditions.

This project is forked from steinfletcher/apitest apitest was functionally complete. However, I wanted more features, so I decided to fork it to actively develop it further. I will mainly enhance document generation and integration with AWS. There are no plans for compatibility between apitest and spectest. Therefore, future development will include BREAKING CHANGES.

The spectest has its own unique use cases, Use Cases of spectest. Please refer to this document for more information.

Supported OS

  • Linux
  • Mac
  • Windows (Original apitest does not support Windows)

Installation

go get -u github.com/go-spectest/spectest

Demo

animated gif

Examples

Framework and library integration examples

Example Comment
gin popular martini-like web framework
graphql using gqlgen.com to generate a graphql server
gorilla the gorilla web toolkit
iris (broken) iris web framework
echo High performance, extensible, minimalist Go web framework
fiber Express inspired web framework written in Go
httprouter High performance HTTP request router that scales well
mocks example mocking out external http calls
sequence diagrams generate sequence diagrams from tests
Ginkgo Ginkgo BDD test framework
plantuml wxample generating plantuml

Companion libraries (Side projects)

In the original apitest repository, side projects were managed in separate repositories. However, in spectest, these side projects are managed within the same repository. However, the difflib, which operates independently from spectest, and the malfunctioning aws package, are managed in separate repositories.

Library Comment
JSON Path JSON Path assertion addons
JOSN Schema JSON Schema assertion addons
CSS Selectors CSS selector assertion addons
PlantUML Export sequence diagrams as plantUML
DynamoDB (broken) Add DynamoDB interactions to sequence diagrams

Credits

This library was influenced by the following software packages:

  • YatSpec for creating sequence diagrams from tests
  • MockMVC and superagent for the concept and behavioral testing approach
  • Gock for the approach to mocking HTTP services in Go
  • Baloo for API design

Code snippets

JSON body matcher
func TestApi(t *testing.T) {
	spectest.New().
		Handler(handler).
		Get("/user/1234").
		Expect(t).
		Body(`{"id": "1234", "name": "Tate"}`).
		Status(http.StatusOK).
		End()
}
JSONPath

For asserting on parts of the response body JSONPath may be used. A separate module must be installed which provides these assertions - go get -u github.com/go-spectest/spectest/jsonpath. This is packaged separately to keep this library dependency free.

Given the response is {"a": 12345, "b": [{"key": "c", "value": "result"}]}

func TestApi(t *testing.T) {
	spectest.Handler(handler).
		Get("/hello").
		Expect(t).
		Assert(jsonpath.Contains(`$.b[? @.key=="c"].value`, "result")).
		End()
}

and jsonpath.Equals checks for value equality

func TestApi(t *testing.T) {
	spectest.Handler(handler).
		Get("/hello").
		Expect(t).
		Assert(jsonpath.Equal(`$.a`, float64(12345))).
		End()
}
Custom assert functions
func TestApi(t *testing.T) {
	spectest.Handler(handler).
		Get("/hello").
		Expect(t).
		Assert(func(res *http.Response, req *http.Request) error {
			assert.Equal(t, http.StatusOK, res.StatusCode)
			return nil
		}).
		End()
}
Assert cookies
func TestApi(t *testing.T) {
	spectest.Handler(handler).
		Patch("/hello").
		Expect(t).
		Status(http.StatusOK).
		Cookies(spectest.Cookie("ABC").Value("12345")).
		CookiePresent("Session-Token").
		CookieNotPresent("XXX").
		Cookies(
			spectest.Cookie("ABC").Value("12345"),
			spectest.Cookie("DEF").Value("67890"),
		).
		End()
}
Assert headers
func TestApi(t *testing.T) {
	spectest.Handler(handler).
		Get("/hello").
		Expect(t).
		Status(http.StatusOK).
		Headers(map[string]string{"ABC": "12345"}).
		End()
}
Mocking external http calls
var getUser = spectest.NewMock().
	Get("/user/12345").
	RespondWith().
	Body(`{"name": "jon", "id": "1234"}`).
	Status(http.StatusOK).
	End()

var getPreferences = spectest.NewMock().
	Get("/preferences/12345").
	RespondWith().
	Body(`{"is_contactable": true}`).
	Status(http.StatusOK).
	End()

func TestApi(t *testing.T) {
	spectest.New().
		Mocks(getUser, getPreferences).
		Handler(handler).
		Get("/hello").
		Expect(t).
		Status(http.StatusOK).
		Body(`{"name": "jon", "id": "1234"}`).
		End()
}
Generating sequence diagrams from tests

func TestApi(t *testing.T) {
	spectest.New().
		Report(spectest.SequenceDiagram()).
		Mocks(getUser, getPreferences).
		Handler(handler).
		Get("/hello").
		Expect(t).
		Status(http.StatusOK).
		Body(`{"name": "jon", "id": "1234"}`).
		End()
}

It is possible to override the default storage location by passing the formatter instance Report(spectest.NewSequenceDiagramFormatter(".sequence-diagrams")). If you want to change the report file name , you use CustomReportName("file name is here") . By default, the hash value becomes the report file name.

You can bring your own formatter too if you want to produce custom output. By default a sequence diagram is rendered on a html page.

The spectest checks the Content Type of the response. If it's an image-related MIME type, the image will be displayed in the report. In the apitest, binary data was being displayed.

DiagramSample

One feature that does not exist in the apitest fork is the ability to output reports in markdown format. The below code snippet is an example of how to output a markdown report.


func TestApi(t *testing.T) {
	spectest.New().
		CustomReportName("markdow_report").
		Report(spectest.SequenceReport(spectest.ReportFormatterConfig{
			Path: "doc",
			Kind: spectest.ReportKindMarkdown,
		})).
		Handler(handler).
		Get("/image").
		Expect(t).
		Body(string(body)).
		Header("Content-Type", "image/png").
		Header("Content-Length", fmt.Sprint(imageInfo.Size())).
		Status(http.StatusOK).
		End()
}

MarkdownReportSample

Debugging http requests and responses generated by api test and any mocks
func TestApi(t *testing.T) {
	spectest.New().
		Debug().
		Handler(handler).
		Get("/hello").
		Expect(t).
		Status(http.StatusOK).
		End()
}
Provide basic auth in the request
func TestApi(t *testing.T) {
	spectest.Handler(handler).
		Get("/hello").
		BasicAuth("username", "password").
		Expect(t).
		Status(http.StatusOK).
		End()
}
Pass a custom context to the request
func TestApi(t *testing.T) {
	spectest.Handler(handler).
		Get("/hello").
		WithContext(context.TODO()).
		Expect(t).
		Status(http.StatusOK).
		End()
}
Provide cookies in the request
func TestApi(t *testing.T) {
	spectest.Handler(handler).
		Get("/hello").
		Cookies(spectest.Cookie("ABC").Value("12345")).
		Expect(t).
		Status(http.StatusOK).
		End()
}
Provide headers in the request
func TestApi(t *testing.T) {
	spectest.Handler(handler).
		Delete("/hello").
		Headers(map[string]string{"My-Header": "12345"}).
		Expect(t).
		Status(http.StatusOK).
		End()
}
Provide query parameters in the request

Query, QueryParams and QueryCollection can all be used in combination

func TestApi(t *testing.T) {
	spectest.Handler(handler).
		Get("/hello").
		QueryParams(map[string]string{"a": "1", "b": "2"}).
		Query("c", "d").
		Expect(t).
		Status(http.StatusOK).
		End()
}

Providing {"a": {"b", "c", "d"} results in parameters encoded as a=b&a=c&a=d. QueryCollection can be used in combination with Query

func TestApi(t *testing.T) {
	spectest.Handler(handler).
		Get("/hello").
		QueryCollection(map[string][]string{"a": {"b", "c", "d"}}).
		Expect(t).
		Status(http.StatusOK).
		End()
}
Provide a url encoded form body in the request
func TestApi(t *testing.T) {
	spectest.Handler(handler).
		Post("/hello").
		FormData("a", "1").
		FormData("b", "2").
		FormData("b", "3").
		FormData("c", "4", "5", "6").
		Expect(t).
		Status(http.StatusOK).
		End()
}
Provide a multipart/form-data
func TestApi(t *testing.T) {
	spectest.Handler(handler).
		Post("/hello").
		MultipartFormData("a", "1", "2").
		MultipartFile("file", "path/to/some.file1", "path/to/some.file2").
		Expect(t).
		Status(http.StatusOK).
		End()
}
Capture the request and response data
func TestApi(t *testing.T) {
	spectest.New().
		Observe(func(res *http.Response, req *http.Request, specTest *spectest.SpecTest) {
			// do something with res and req
		}).
		Handler(handler).
		Get("/hello").
		Expect(t).
		Status(http.StatusOK).
		End()
}
Intercept the request

This is useful for mutating the request before it is sent to the system under test.

func TestApi(t *testing.T) {
	spectest.Handler(handler).
		Intercept(func(req *http.Request) {
			req.URL.RawQuery = "a[]=xxx&a[]=yyy"
		}).
		Get("/hello").
		Expect(t).
		Status(http.StatusOK).
		End()
}

Contributing

View the contributing guide.

Documentation

Overview

Package spectest is simple and extensible behavioral testing library for Go. You can use api test to simplify REST API, HTTP handler and e2e tests. (forked from steinfletcher/apitest)

Index

Examples

Constants

View Source
const ConsumerDefaultName = "client"

ConsumerDefaultName default consumer name

View Source
const SystemUnderTestDefaultName = "server"

SystemUnderTestDefaultName default name for system under test

Variables

View Source
var (
	// ErrTimeout is an error that indicates a timeout.
	ErrTimeout = errors.New("deadline exceeded")
)

Functions

This section is empty.

Types

type Assert

type Assert func(*http.Response, *http.Request) error

Assert is a user defined custom assertion function

var IsClientError Assert = func(response *http.Response, request *http.Request) error {
	if response.StatusCode >= http.StatusBadRequest && response.StatusCode < http.StatusInternalServerError {
		return nil
	}
	return fmt.Errorf("not a client error. Status code=%d", response.StatusCode)
}

IsClientError is a convenience function to assert on a range of client error status codes

var IsServerError Assert = func(response *http.Response, request *http.Request) error {
	if response.StatusCode >= http.StatusInternalServerError {
		return nil
	}
	return fmt.Errorf("not a server error. Status code=%d", response.StatusCode)
}

IsServerError is a convenience function to assert on a range of server error status codes

var IsSuccess Assert = func(response *http.Response, request *http.Request) error {
	if response.StatusCode >= http.StatusOK && response.StatusCode < http.StatusBadRequest {
		return nil
	}
	return fmt.Errorf("not success. Status code=%d", response.StatusCode)
}

IsSuccess is a convenience function to assert on a range of happy path status codes

type Cookie struct {
	// contains filtered or unexported fields
}

Cookie used to represent an http cookie

func FromHTTPCookie

func FromHTTPCookie(httpCookie *http.Cookie) *Cookie

FromHTTPCookie transforms an http cookie into a Cookie

func NewCookie

func NewCookie(name string) *Cookie

NewCookie creates a new Cookie with the provided name

func (*Cookie) Domain

func (cookie *Cookie) Domain(domain string) *Cookie

Domain sets the domain of the Cookie

func (*Cookie) Expires

func (cookie *Cookie) Expires(expires time.Time) *Cookie

Expires sets the expires time of the Cookie

func (*Cookie) HTTPOnly

func (cookie *Cookie) HTTPOnly(httpOnly bool) *Cookie

HTTPOnly sets the httpOnly bool of the Cookie

func (*Cookie) MaxAge

func (cookie *Cookie) MaxAge(maxAge int) *Cookie

MaxAge sets the max age of the Cookie

func (*Cookie) Path

func (cookie *Cookie) Path(path string) *Cookie

Path sets the path of the Cookie

func (*Cookie) Secure

func (cookie *Cookie) Secure(secure bool) *Cookie

Secure sets the secure bool of the Cookie

func (*Cookie) ToHTTPCookie

func (cookie *Cookie) ToHTTPCookie() *http.Cookie

ToHTTPCookie transforms the Cookie to an http cookie

func (*Cookie) Value

func (cookie *Cookie) Value(value string) *Cookie

Value sets the value of the Cookie

type DefaultVerifier

type DefaultVerifier struct{}

DefaultVerifier is a verifier that uses some code from https://github.com/stretchr/testify to perform assertions

func (DefaultVerifier) Equal

func (a DefaultVerifier) Equal(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool

Equal asserts that two values are equal

func (DefaultVerifier) Fail

func (a DefaultVerifier) Fail(t TestingT, failureMessage string, msgAndArgs ...interface{}) bool

Fail reports a failure

func (DefaultVerifier) JSONEq

func (a DefaultVerifier) JSONEq(t TestingT, expected string, actual string, msgAndArgs ...interface{}) bool

JSONEq asserts that two JSON strings are equivalent

func (DefaultVerifier) NoError

func (a DefaultVerifier) NoError(t TestingT, err error, msgAndArgs ...interface{}) bool

NoError asserts that a function returned no error

func (DefaultVerifier) True

func (a DefaultVerifier) True(t TestingT, value bool, msgAndArgs ...interface{}) bool

True asserts that the value is true

type Event

type Event interface {
	GetTime() time.Time
}

Event represents a reporting event e.g. HTTPRequest, HTTPResponse, MessageRequest, MessageResponse

type GraphQLRequestBody

type GraphQLRequestBody struct {
	Query         string                 `json:"query"`
	Variables     map[string]interface{} `json:"variables,omitempty"`
	OperationName string                 `json:"operation_name,omitempty"`
}

GraphQLRequestBody represents the POST request body as per the GraphQL spec

type HTTPRequest

type HTTPRequest struct {
	Source    string
	Target    string
	Value     *http.Request
	Timestamp time.Time
}

HTTPRequest represents an http request

func (HTTPRequest) GetTime

func (r HTTPRequest) GetTime() time.Time

GetTime gets the time of the HTTPRequest interaction

type HTTPResponse

type HTTPResponse struct {
	Source    string
	Target    string
	Value     *http.Response
	Timestamp time.Time
}

HTTPResponse represents an http response

func (HTTPResponse) GetTime

func (r HTTPResponse) GetTime() time.Time

GetTime gets the time of the HTTPResponse interaction

type Intercept

type Intercept func(*http.Request)

Intercept will be called before the request is made. Updates to the request will be reflected in the test

type Interval added in v0.0.4

type Interval struct {
	// Started is the Started time of the interval.
	Started time.Time
	// Finished is the Finished time of the interval.
	Finished time.Time
}

Interval represents a time interval.

func NewInterval added in v0.0.4

func NewInterval() *Interval

NewInterval creates a new interval. This method is not set the start and end time of the interval.

func (Interval) Duration added in v0.0.4

func (i Interval) Duration() time.Duration

Duration returns the duration of the interval.

Example

nolint

package main

import (
	"fmt"
	"testing"
	"time"

	"github.com/go-spectest/spectest"
	"github.com/tenntenn/testtime"
)

func main() {
	t := &testing.T{}
	interval := spectest.NewInterval()

	// Set started time. Usually, you don't need to set the time. You only call Start() method.
	if !testtime.SetTime(t, time.Date(2023, 1, 1, 0, 0, 0, 0, time.UTC)) {
		t.Fatal("failed to set start time")
	}
	interval.Start()

	// Set finished time. Usually, you don't need to set the time. You only call End() method.
	if !testtime.SetTime(t, time.Date(2023, 1, 1, 0, 0, 1, 0, time.UTC)) {
		t.Fatal("failed to set end time")
	}
	interval.End()

	fmt.Printf("duration=%f[s]", interval.Duration().Seconds())
}
Output:

duration=1.000000[s]

func (*Interval) End added in v0.0.4

func (i *Interval) End() *Interval

End sets the end time of the interval.

func (*Interval) Start added in v0.0.4

func (i *Interval) Start() *Interval

Start sets the start time of the interval.

type LogEntry

type LogEntry struct {
	// Header is the header of the log entry.
	// e.g.  "GET /path HTTP/1.1\r\nHost: example.com\r\n\r\n",
	Header string
	// Body is the body of the log entry.
	Body string
	// Timestamp is the timestamp of the log entry. It does not set when the log entry is created.
	Timestamp time.Time
}

LogEntry represents a single log entry that is used to generate the web sequence diagram. It contains the header, body and timestamp of the log entry.

func NewHTTPRequestLogEntry

func NewHTTPRequestLogEntry(req *http.Request) (LogEntry, error)

NewHTTPRequestLogEntry creates a new LogEntry from a http.Request.

func NewHTTPResponseLogEntry

func NewHTTPResponseLogEntry(res *http.Response) (LogEntry, error)

NewHTTPResponseLogEntry creates a new LogEntry from a http.Response.

type MarkdownFormatter added in v0.0.9

type MarkdownFormatter struct {
	// contains filtered or unexported fields
}

MarkdownFormatter implementation of a ReportFormatter

func (*MarkdownFormatter) Format added in v0.0.9

func (m *MarkdownFormatter) Format(recorder *Recorder)

Format formats the events received by the recorder. TODO: refactor this method

type Matcher

type Matcher func(*http.Request, *MockRequest) error

Matcher type accepts the actual request and a mock request to match against. Will return an error that describes why there was a mismatch if the inputs do not match or nil if they do.

type MessageRequest

type MessageRequest struct {
	Source    string
	Target    string
	Header    string
	Body      string
	Timestamp time.Time
}

MessageRequest represents a request interaction

func (MessageRequest) GetTime

func (r MessageRequest) GetTime() time.Time

GetTime gets the time of the MessageRequest interaction

type MessageResponse

type MessageResponse struct {
	Source    string
	Target    string
	Header    string
	Body      string
	Timestamp time.Time
}

MessageResponse represents a response interaction

func (MessageResponse) GetTime

func (r MessageResponse) GetTime() time.Time

GetTime gets the time of the MessageResponse interaction

type Meta

type Meta struct {
	// ConsumerName represents the name of the consumer.
	ConsumerName string `json:"consumer_name,omitempty"`
	// Duration represents the duration of the report.
	// This is the time between the first request and the last response.
	Duration int64 `json:"duration,omitempty"`
	// Host represents the host of the report. e.g. example.com
	Host string `json:"host,omitempty"`
	// Method represents http request method of the report.
	Method string `json:"method,omitempty"`
	// Name represents the title of the report.
	Name string `json:"name,omitempty"`
	// Path represents http request url of the report. e.g. /api/v1/users
	Path string `json:"path,omitempty"`
	// ReportFileName represents the name of the report file.
	ReportFileName string `json:"report_file_name,omitempty"`
	// StatusCode represents the final http status code of the report.
	StatusCode int `json:"status_code,omitempty"`
	// TestingTargetName represents the name of the system under test.
	TestingTargetName string `json:"testing_target_name,omitempty"`
}

Meta represents the meta data for the report.

type Mock

type Mock struct {
	// contains filtered or unexported fields
}

Mock represents the entire interaction for a mock to be used for testing

func NewMock

func NewMock() *Mock

NewMock create a new mock, ready for configuration using the builder pattern

func (*Mock) Connect added in v0.0.4

func (m *Mock) Connect(u string) *MockRequest

Connect configures the mock to match http method CONNECT

func (*Mock) Connectf added in v0.0.4

func (m *Mock) Connectf(format string, args ...interface{}) *MockRequest

Connectf configures the mock to match http method CONNECT and supports formatting

func (*Mock) Debug

func (m *Mock) Debug() *Mock

Debug is used to set debug mode for mocks in standalone mode. This is overridden by the debug setting in the `SpecTest` struct

func (*Mock) Delete

func (m *Mock) Delete(u string) *MockRequest

Delete configures the mock to match http method DELETE

func (*Mock) Deletef

func (m *Mock) Deletef(format string, args ...interface{}) *MockRequest

Deletef configures the mock to match http method DELETE and supports formatting

func (*Mock) Get

func (m *Mock) Get(u string) *MockRequest

Get configures the mock to match http method GET

func (*Mock) Getf

func (m *Mock) Getf(format string, args ...interface{}) *MockRequest

Getf configures the mock to match http method GET and supports formatting

func (*Mock) HTTPClient added in v0.0.2

func (m *Mock) HTTPClient(cli *http.Client) *Mock

HTTPClient allows the developer to provide a custom http client when using mocks

func (*Mock) Head

func (m *Mock) Head(u string) *MockRequest

Head configures the mock to match http method HEAD

func (*Mock) Headf added in v0.0.4

func (m *Mock) Headf(format string, args ...interface{}) *MockRequest

Headf configures the mock to match http method HEAD and supports formatting

func (*Mock) Matches

func (m *Mock) Matches(req *http.Request) []error

Matches checks whether the given request matches the mock

func (*Mock) Method

func (m *Mock) Method(method string) *MockRequest

Method configures mock to match given http method

func (*Mock) Options added in v0.0.4

func (m *Mock) Options(u string) *MockRequest

Options configures the mock to match http method OPTIONS

func (*Mock) Optionsf added in v0.0.4

func (m *Mock) Optionsf(format string, args ...interface{}) *MockRequest

Optionsf configures the mock to match http method OPTIONS and supports formatting

func (*Mock) Patch

func (m *Mock) Patch(u string) *MockRequest

Patch configures the mock to match http method PATCH

func (*Mock) Patchf

func (m *Mock) Patchf(format string, args ...interface{}) *MockRequest

Patchf configures the mock to match http method PATCH and supports formatting

func (*Mock) Post

func (m *Mock) Post(u string) *MockRequest

Post configures the mock to match http method POST

func (*Mock) Postf

func (m *Mock) Postf(format string, args ...interface{}) *MockRequest

Postf configures the mock to match http method POST and supports formatting

func (*Mock) Put

func (m *Mock) Put(u string) *MockRequest

Put configures the mock to match http method PUT

func (*Mock) Putf

func (m *Mock) Putf(format string, args ...interface{}) *MockRequest

Putf configures the mock to match http method PUT and supports formatting

func (*Mock) Trace added in v0.0.4

func (m *Mock) Trace(u string) *MockRequest

Trace configures the mock to match http method TRACE

func (*Mock) Tracef added in v0.0.4

func (m *Mock) Tracef(format string, args ...interface{}) *MockRequest

Tracef configures the mock to match http method TRACE and supports formatting

type MockRequest

type MockRequest struct {
	// contains filtered or unexported fields
}

MockRequest represents the http request side of a mock interaction

func (*MockRequest) AddMatcher

func (r *MockRequest) AddMatcher(matcher Matcher) *MockRequest

AddMatcher configures the mock request to match using a custom matcher

func (*MockRequest) BasicAuth

func (r *MockRequest) BasicAuth(userName, password string) *MockRequest

BasicAuth configures the mock request to match the given basic auth parameters

func (*MockRequest) Body

func (r *MockRequest) Body(b string) *MockRequest

Body configures the mock request to match the given body

func (*MockRequest) BodyFromFile

func (r *MockRequest) BodyFromFile(f string) *MockRequest

BodyFromFile configures the mock request to match the given body from a file

func (*MockRequest) BodyRegexp

func (r *MockRequest) BodyRegexp(b string) *MockRequest

BodyRegexp configures the mock request to match the given body using the regexp matcher

func (*MockRequest) Bodyf

func (r *MockRequest) Bodyf(format string, args ...interface{}) *MockRequest

Bodyf configures the mock request to match the given body. Supports formatting the body

func (*MockRequest) Cookie

func (r *MockRequest) Cookie(name, value string) *MockRequest

Cookie configures the mock request to match a cookie

func (*MockRequest) CookieNotPresent

func (r *MockRequest) CookieNotPresent(name string) *MockRequest

CookieNotPresent configures the mock request to match when a cookie is not present

func (*MockRequest) CookiePresent

func (r *MockRequest) CookiePresent(name string) *MockRequest

CookiePresent configures the mock request to match when a cookie is present, regardless of value

func (*MockRequest) FormData

func (r *MockRequest) FormData(key string, values ...string) *MockRequest

FormData configures the mock request to math the given form data

func (*MockRequest) FormDataNotPresent

func (r *MockRequest) FormDataNotPresent(key string) *MockRequest

FormDataNotPresent configures the mock request to match when the form data is not present

func (*MockRequest) FormDataPresent

func (r *MockRequest) FormDataPresent(key string) *MockRequest

FormDataPresent configures the mock request to match when the form data is present, regardless of values

func (*MockRequest) Header

func (r *MockRequest) Header(key, value string) *MockRequest

Header configures the mock request to match the given header

func (*MockRequest) HeaderNotPresent

func (r *MockRequest) HeaderNotPresent(key string) *MockRequest

HeaderNotPresent configures the mock request to match when the header is not present

func (*MockRequest) HeaderPresent

func (r *MockRequest) HeaderPresent(key string) *MockRequest

HeaderPresent configures the mock request to match when this header is present, regardless of value

func (*MockRequest) Headers

func (r *MockRequest) Headers(headers map[string]string) *MockRequest

Headers configures the mock request to match the given headers

func (*MockRequest) JSON

func (r *MockRequest) JSON(v interface{}) *MockRequest

JSON is a convenience method for setting the mock request body

func (*MockRequest) Query

func (r *MockRequest) Query(key, value string) *MockRequest

Query configures the mock request to match a query param

func (*MockRequest) QueryCollection

func (r *MockRequest) QueryCollection(queryParams map[string][]string) *MockRequest

QueryCollection configures the mock request to match a number of repeating query params, e.g. ?a=1&a=2&a=3

func (*MockRequest) QueryNotPresent

func (r *MockRequest) QueryNotPresent(key string) *MockRequest

QueryNotPresent configures the mock request to match when the query param is not present

func (*MockRequest) QueryParams

func (r *MockRequest) QueryParams(queryParams map[string]string) *MockRequest

QueryParams configures the mock request to match a number of query params

func (*MockRequest) QueryPresent

func (r *MockRequest) QueryPresent(key string) *MockRequest

QueryPresent configures the mock request to match when a query param is present, regardless of value

func (*MockRequest) RespondWith

func (r *MockRequest) RespondWith() *MockResponse

RespondWith finalizes the mock request phase of set up and allowing the definition of response attributes to be defined

type MockResponse

type MockResponse struct {
	// contains filtered or unexported fields
}

MockResponse represents the http response side of a mock interaction

func (*MockResponse) Body

func (r *MockResponse) Body(body string) *MockResponse

Body sets the mock response body

func (*MockResponse) BodyFromFile

func (r *MockResponse) BodyFromFile(f string) *MockResponse

BodyFromFile defines the mock response body from a file

func (*MockResponse) Bodyf

func (r *MockResponse) Bodyf(format string, args ...interface{}) *MockResponse

Bodyf sets the mock response body. Supports formatting

func (*MockResponse) Cookie

func (r *MockResponse) Cookie(name, value string) *MockResponse

Cookie respond with the given cookie

func (*MockResponse) Cookies

func (r *MockResponse) Cookies(cookie ...*Cookie) *MockResponse

Cookies respond with the given cookies

func (*MockResponse) End

func (r *MockResponse) End() *Mock

End finalizes the response definition phase in order for the mock to be used

func (*MockResponse) EndStandalone

func (r *MockResponse) EndStandalone(other ...*Mock) func()

EndStandalone finalizes the response definition of standalone mocks

func (*MockResponse) FixedDelay

func (r *MockResponse) FixedDelay(delay int64) *MockResponse

FixedDelay will return the response after the given number of milliseconds. SpecTest::EnableMockResponseDelay must be set for this to take effect. If Timeout is set this has no effect.

func (*MockResponse) Header

func (r *MockResponse) Header(key string, value string) *MockResponse

Header respond with the given header

func (*MockResponse) Headers

func (r *MockResponse) Headers(headers map[string]string) *MockResponse

Headers respond with the given headers

func (*MockResponse) JSON

func (r *MockResponse) JSON(v interface{}) *MockResponse

JSON is a convenience method for setting the mock response body

func (*MockResponse) Status

func (r *MockResponse) Status(statusCode int) *MockResponse

Status respond with the given status

func (*MockResponse) Timeout

func (r *MockResponse) Timeout() *MockResponse

Timeout forces the mock to return a http timeout

func (*MockResponse) Times

func (r *MockResponse) Times(times uint) *MockResponse

Times respond the given number of times

type Mocks added in v0.0.14

type Mocks []*Mock

Mocks is a slice of Mock

type NoopVerifier

type NoopVerifier struct{}

NoopVerifier is a verifier that does not perform verification

func (NoopVerifier) Equal

func (n NoopVerifier) Equal(_ TestingT, _, _ interface{}, _ ...interface{}) bool

Equal does not perform any assertion and always returns true

func (NoopVerifier) Fail

func (n NoopVerifier) Fail(_ TestingT, _ string, _ ...interface{}) bool

Fail does not perform any assertion and always returns true

func (NoopVerifier) JSONEq

func (n NoopVerifier) JSONEq(_ TestingT, _ string, _ string, _ ...interface{}) bool

JSONEq does not perform any assertion and always returns true

func (NoopVerifier) NoError

func (n NoopVerifier) NoError(_ TestingT, _ error, _ ...interface{}) bool

NoError asserts that a function returned no error

func (NoopVerifier) True

func (n NoopVerifier) True(_ TestingT, _ bool, _ ...interface{}) bool

True is always true

type Observe

type Observe func(*http.Response, *http.Request, *SpecTest)

Observe will be called by with the request and response on completion

type Recorder

type Recorder struct {
	// Title is the title of the report
	Title string
	// SubTitle is the subtitle of the report
	SubTitle string
	// Meta is the meta data of the report.
	Meta *Meta
	// Events is the list of events that occurred during the test
	Events []Event
}

Recorder represents all of the report data

func NewTestRecorder

func NewTestRecorder() *Recorder

NewTestRecorder creates a new TestRecorder

func (*Recorder) AddHTTPRequest

func (r *Recorder) AddHTTPRequest(req HTTPRequest) *Recorder

AddHTTPRequest add an http request to recorder

func (*Recorder) AddHTTPResponse

func (r *Recorder) AddHTTPResponse(req HTTPResponse) *Recorder

AddHTTPResponse add an HTTPResponse to the recorder

func (*Recorder) AddMessageRequest

func (r *Recorder) AddMessageRequest(m MessageRequest) *Recorder

AddMessageRequest add a MessageRequest to the recorder

func (*Recorder) AddMessageResponse

func (r *Recorder) AddMessageResponse(m MessageResponse) *Recorder

AddMessageResponse add a MessageResponse to the recorder

func (*Recorder) AddMeta

func (r *Recorder) AddMeta(meta *Meta) *Recorder

AddMeta add Meta to the recorder

func (*Recorder) AddSubTitle

func (r *Recorder) AddSubTitle(subTitle string) *Recorder

AddSubTitle add a SubTitle to the recorder

func (*Recorder) AddTitle

func (r *Recorder) AddTitle(title string) *Recorder

AddTitle add a Title to the recorder

func (*Recorder) Reset

func (r *Recorder) Reset()

Reset resets the recorder to default starting state

func (*Recorder) ResponseStatus

func (r *Recorder) ResponseStatus() (int, error)

ResponseStatus get response status of the recorder, returning an error when this wasn't possible

type ReportFormatter

type ReportFormatter interface {
	// Format formats the events received from the recorder
	Format(*Recorder)
}

ReportFormatter represents the report formatter

func SequenceDiagram

func SequenceDiagram(path ...string) ReportFormatter

SequenceDiagram produce a sequence diagram at the given path or .sequence by default. SequenceDiagramFormatter generate html report with sequence diagram. Deprecated: Use SequenceReport instead.

func SequenceReport added in v0.0.9

func SequenceReport(config ReportFormatterConfig) ReportFormatter

SequenceReport produce a sequence diagram at the given path or .sequence by default. SequenceDiagramFormatter generate html report or markdown report with sequence diagram.

type ReportFormatterConfig added in v0.0.9

type ReportFormatterConfig struct {
	// Path is the path where the report will be saved.
	// By default, the report will be saved in the ".sequence"
	Path string
	// Kind is the kind of report to generate
	Kind ReportKind
}

ReportFormatterConfig is the configuration for a ReportFormatter

type ReportKind added in v0.0.9

type ReportKind uint

ReportKind is the kind of the report.

const (
	// ReportKindHTML is the HTML report kind. This is the default.
	ReportKindHTML ReportKind = 0
	// ReportKindMarkdown is the Markdown report kind.
	ReportKindMarkdown ReportKind = 1
)

type Request

type Request struct {
	// contains filtered or unexported fields
}

Request is the user defined request that will be invoked on the handler under test

func (*Request) BasicAuth

func (r *Request) BasicAuth(username, password string) *Request

BasicAuth is a builder method to sets basic auth on the request.

func (*Request) Body

func (r *Request) Body(b string) *Request

Body is a builder method to set the request body

func (*Request) BodyFromFile

func (r *Request) BodyFromFile(f string) *Request

BodyFromFile is a builder method to set the request body

func (*Request) Bodyf

func (r *Request) Bodyf(format string, args ...interface{}) *Request

Bodyf sets the request body and supports a formatter

func (*Request) ContentType

func (r *Request) ContentType(contentType string) *Request

ContentType is a builder method to set the Content-Type header of the request

func (*Request) Cookie

func (r *Request) Cookie(name, value string) *Request

Cookie is a convenience method for setting a single request cookies by name and value

func (*Request) Cookies

func (r *Request) Cookies(c ...*Cookie) *Request

Cookies is a builder method to set the request cookies

func (*Request) Expect

func (r *Request) Expect(t TestingT) *Response

Expect marks the request spec as complete and following code will define the expected response

func (*Request) FormData

func (r *Request) FormData(name string, values ...string) *Request

FormData is a builder method to set the body form data Also sets the content type of the request to application/x-www-form-urlencoded

func (*Request) GraphQLQuery

func (r *Request) GraphQLQuery(query string, variables ...map[string]interface{}) *Request

GraphQLQuery is a convenience method for building a graphql POST request

func (*Request) GraphQLRequest

func (r *Request) GraphQLRequest(body GraphQLRequestBody) *Request

GraphQLRequest builds a graphql POST request

func (*Request) Header

func (r *Request) Header(key, value string) *Request

Header is a builder method to set the request headers

func (*Request) Headers

func (r *Request) Headers(headers map[string]string) *Request

Headers is a builder method to set the request headers

func (*Request) JSON

func (r *Request) JSON(v interface{}) *Request

JSON is a convenience method for setting the request body and content type header as "application/json". If v is not a string or []byte it will marshall the provided variable as json

func (*Request) JSONFromFile

func (r *Request) JSONFromFile(f string) *Request

JSONFromFile is a convenience method for setting the request body and content type header as "application/json"

func (*Request) MultipartFile

func (r *Request) MultipartFile(name string, ff ...string) *Request

MultipartFile is a builder method to set the file in multipart form data Also sets the content type of the request to multipart/form-data

func (*Request) MultipartFormData

func (r *Request) MultipartFormData(name string, values ...string) *Request

MultipartFormData is a builder method to set the field in multipart form data Also sets the content type of the request to multipart/form-data

func (*Request) Query

func (r *Request) Query(key, value string) *Request

Query is a convenience method to add a query parameter to the request.

func (*Request) QueryCollection

func (r *Request) QueryCollection(q map[string][]string) *Request

QueryCollection is a builder method to set the request query parameters This can be used in combination with request.Query

func (*Request) QueryParams

func (r *Request) QueryParams(params map[string]string) *Request

QueryParams is a builder method to set the request query parameters. This can be used in combination with request.QueryCollection

func (*Request) URL

func (r *Request) URL(url string) *Request

URL is a builder method for setting the url of the request

func (*Request) URLf

func (r *Request) URLf(format string, args ...interface{}) *Request

URLf is a builder method for setting the url of the request and supports a formatter

func (*Request) WithContext

func (r *Request) WithContext(ctx context.Context) *Request

WithContext is a builder method to set a context on the request

type Response

type Response struct {
	// contains filtered or unexported fields
}

Response is the user defined expected response from the application under test

func (*Response) Assert

func (r *Response) Assert(fn func(*http.Response, *http.Request) error) *Response

Assert allows the consumer to provide a user defined function containing their own custom assertions

func (*Response) Body

func (r *Response) Body(b string) *Response

Body is the expected response body

func (*Response) BodyFromFile

func (r *Response) BodyFromFile(path string) *Response

BodyFromFile reads the given file and uses the content as the expected response body

func (*Response) BodyFromGoldenFile added in v0.0.15

func (r *Response) BodyFromGoldenFile(path string) *Response

BodyFromGoldenFile reads the given file and uses the content as the expected response body. If the update flag is set, the golden file will be updated with the actual response body. Example: go test -update

func (*Response) Bodyf

func (r *Response) Bodyf(format string, args ...interface{}) *Response

Bodyf is the expected response body that supports a formatter

func (*Response) Cookie

func (r *Response) Cookie(name, value string) *Response

Cookie is used to match on an individual cookie name/value pair in the expected response cookies

func (*Response) CookieNotPresent

func (r *Response) CookieNotPresent(cookieName string) *Response

CookieNotPresent is used to assert that a cookie is not present in the response

func (*Response) CookiePresent

func (r *Response) CookiePresent(cookieName string) *Response

CookiePresent is used to assert that a cookie is present in the response, regardless of its value

func (*Response) Cookies

func (r *Response) Cookies(cookies ...*Cookie) *Response

Cookies is the expected response cookies

func (*Response) End

func (r *Response) End() Result

End runs the test returning the result to the caller

func (*Response) Header

func (r *Response) Header(key, value string) *Response

Header is a builder method to set the request headers

func (*Response) HeaderNotPresent

func (r *Response) HeaderNotPresent(name string) *Response

HeaderNotPresent is a builder method to set the request headers that should not be present in the response

func (*Response) HeaderPresent

func (r *Response) HeaderPresent(name string) *Response

HeaderPresent is a builder method to set the request headers that should be present in the response

func (*Response) Headers

func (r *Response) Headers(headers map[string]string) *Response

Headers is a builder method to set the request headers

func (*Response) Status

func (r *Response) Status(s int) *Response

Status is the expected response http status code

type Result

type Result struct {
	Response *http.Response
	// contains filtered or unexported fields
}

Result provides the final result

func (Result) JSON

func (r Result) JSON(t interface{})

JSON unmarshal the result response body to a valid struct

func (Result) UnmatchedMocks

func (r Result) UnmatchedMocks() []UnmatchedMock

UnmatchedMocks returns any mocks that were not used, e.g. there was not a matching http Request for the mock

type SequenceDiagramFormatter

type SequenceDiagramFormatter struct {
	// contains filtered or unexported fields
}

SequenceDiagramFormatter implementation of a ReportFormatter

func (*SequenceDiagramFormatter) Format

func (sdf *SequenceDiagramFormatter) Format(recorder *Recorder)

Format formats the events received by the recorder

type SpecTest added in v0.0.3

type SpecTest struct {
	// contains filtered or unexported fields
}

SpecTest is the top level struct holding the test spec

func Handler

func Handler(handler http.Handler) *SpecTest

Handler is a convenience method for creating a new spectest with a handler

func HandlerFunc

func HandlerFunc(handlerFunc http.HandlerFunc) *SpecTest

HandlerFunc is a convenience method for creating a new spectest with a handler func

func New

func New(name ...string) *SpecTest

New creates a new api test. The name is optional and will appear in test reports. The name is only used name[0]. name[1]... are ignored.

func (*SpecTest) Connect added in v0.0.3

func (s *SpecTest) Connect(url string) *Request

Connect is a convenience method for setting the request as http.MethodConnect

func (*SpecTest) Connectf added in v0.0.3

func (s *SpecTest) Connectf(format string, args ...interface{}) *Request

Connectf is a convenience method that adds formatting support to Connect

func (*SpecTest) CustomHost added in v0.0.3

func (s *SpecTest) CustomHost(host string) *SpecTest

CustomHost set hostname. This method is not change the host in the request. It is only for the report.

func (*SpecTest) CustomReportName added in v0.0.3

func (s *SpecTest) CustomReportName(name string) *SpecTest

CustomReportName allows the consumer to override the default report file name.

func (*SpecTest) Debug added in v0.0.3

func (s *SpecTest) Debug() *SpecTest

Debug logs to the console the http wire representation of all http interactions that are intercepted by spectest. This includes the inbound request to the application under test, the response returned by the application and any interactions that are intercepted by the mock server.

func (*SpecTest) Delete added in v0.0.3

func (s *SpecTest) Delete(url string) *Request

Delete is a convenience method for setting the request as http.MethodDelete

func (*SpecTest) Deletef added in v0.0.3

func (s *SpecTest) Deletef(format string, args ...interface{}) *Request

Deletef is a convenience method that adds formatting support to Delete

func (*SpecTest) EnableMockResponseDelay added in v0.0.3

func (s *SpecTest) EnableMockResponseDelay() *SpecTest

EnableMockResponseDelay turns on mock response delays (defaults to OFF)

func (*SpecTest) EnableNetworking added in v0.0.3

func (s *SpecTest) EnableNetworking(clients ...*http.Client) *SpecTest

EnableNetworking will enable networking for provided clients If no clients are provided, the default http client will be used. If multiple clients are provided, the first client will be used.

func (*SpecTest) Get added in v0.0.3

func (s *SpecTest) Get(url string) *Request

Get is a convenience method for setting the request as http.MethodGet

func (*SpecTest) Getf added in v0.0.3

func (s *SpecTest) Getf(format string, args ...interface{}) *Request

Getf is a convenience method that adds formatting support to Get

func (*SpecTest) HTTPClient added in v0.0.3

func (s *SpecTest) HTTPClient(client *http.Client) *SpecTest

HTTPClient allows the developer to provide a custom http client when using mocks

func (*SpecTest) HTTPRequest added in v0.0.3

func (s *SpecTest) HTTPRequest(req *http.Request) *Request

HTTPRequest defines the native `http.Request`

func (*SpecTest) Handler added in v0.0.3

func (s *SpecTest) Handler(handler http.Handler) *SpecTest

Handler defines the http handler that is invoked when the test is run

func (*SpecTest) HandlerFunc added in v0.0.3

func (s *SpecTest) HandlerFunc(handlerFunc http.HandlerFunc) *SpecTest

HandlerFunc defines the http handler that is invoked when the test is run

func (*SpecTest) Head added in v0.0.3

func (s *SpecTest) Head(url string) *Request

Head is a convenience method for setting the request as http.MethodHead

func (*SpecTest) Headf added in v0.0.3

func (s *SpecTest) Headf(format string, args ...interface{}) *Request

Headf is a convenience method that adds formatting support to Head

func (*SpecTest) Intercept added in v0.0.3

func (s *SpecTest) Intercept(interceptor Intercept) *SpecTest

Intercept is a builder method for setting the request interceptor

func (*SpecTest) Method added in v0.0.3

func (s *SpecTest) Method(method string) *Request

Method is a builder method for setting the http method of the request

func (*SpecTest) Mocks added in v0.0.3

func (s *SpecTest) Mocks(mocks ...*Mock) *SpecTest

Mocks is a builder method for setting the mocks. A mock that expects multiple executions will reset the expected call count to 1 when generated as a mock that expects a single execution.

func (*SpecTest) Observe added in v0.0.3

func (s *SpecTest) Observe(observers ...Observe) *SpecTest

Observe is a builder method for setting the observers

func (*SpecTest) ObserveMocks added in v0.0.3

func (s *SpecTest) ObserveMocks(observer Observe) *SpecTest

ObserveMocks is a builder method for setting the mocks observers

func (*SpecTest) Options added in v0.0.3

func (s *SpecTest) Options(url string) *Request

Options is a convenience method for setting the request as http.MethodOptions

func (*SpecTest) Optionsf added in v0.0.3

func (s *SpecTest) Optionsf(format string, args ...interface{}) *Request

Optionsf is a convenience method that adds formatting support to Options

func (*SpecTest) Patch added in v0.0.3

func (s *SpecTest) Patch(url string) *Request

Patch is a convenience method for setting the request as http.MethodPatch

func (*SpecTest) Patchf added in v0.0.3

func (s *SpecTest) Patchf(format string, args ...interface{}) *Request

Patchf is a convenience method that adds formatting support to Patch

func (*SpecTest) Post added in v0.0.3

func (s *SpecTest) Post(url string) *Request

Post is a convenience method for setting the request as http.MethodPost

func (*SpecTest) Postf added in v0.0.3

func (s *SpecTest) Postf(format string, args ...interface{}) *Request

Postf is a convenience method that adds formatting support to Post

func (*SpecTest) Put added in v0.0.3

func (s *SpecTest) Put(url string) *Request

Put is a convenience method for setting the request as http.MethodPut

func (*SpecTest) Putf added in v0.0.3

func (s *SpecTest) Putf(format string, args ...interface{}) *Request

Putf is a convenience method that adds formatting support to Put

func (*SpecTest) Recorder added in v0.0.3

func (s *SpecTest) Recorder(recorder *Recorder) *SpecTest

Recorder provides a hook to add a recorder to the test

func (*SpecTest) Report added in v0.0.3

func (s *SpecTest) Report(reporter ReportFormatter) *SpecTest

Report provides a hook to add custom formatting to the output of the test

func (*SpecTest) Request added in v0.0.3

func (s *SpecTest) Request() *Request

Request returns the request spec

func (*SpecTest) Response added in v0.0.3

func (s *SpecTest) Response() *Response

Response returns the expected response

func (*SpecTest) Trace added in v0.0.3

func (s *SpecTest) Trace(url string) *Request

Trace is a convenience method for setting the request as http.MethodTrace

func (*SpecTest) Tracef added in v0.0.3

func (s *SpecTest) Tracef(format string, args ...interface{}) *Request

Tracef is a convenience method that adds formatting support to Trace

func (*SpecTest) Verifier added in v0.0.3

func (s *SpecTest) Verifier(v Verifier) *SpecTest

Verifier allows consumers to override the verification implementation.

type StandaloneMocks

type StandaloneMocks struct {
	// contains filtered or unexported fields
}

StandaloneMocks for using mocks outside of API tests context

func NewStandaloneMocks

func NewStandaloneMocks(mocks ...*Mock) *StandaloneMocks

NewStandaloneMocks create a series of StandaloneMocks

func (*StandaloneMocks) Debug

func (r *StandaloneMocks) Debug() *StandaloneMocks

Debug switch on debugging mode

func (*StandaloneMocks) End

func (r *StandaloneMocks) End() func()

End finalizes the mock, ready for use

func (*StandaloneMocks) HTTPClient added in v0.0.2

func (r *StandaloneMocks) HTTPClient(cli *http.Client) *StandaloneMocks

HTTPClient use the given http client

type TestingT

type TestingT interface {
	// Errorf is equivalent to Log followed by Fail
	Errorf(format string, args ...interface{})
	// Fatal is equivalent to Log followed by FailNow
	Fatal(args ...interface{})
	// Fatalf is equivalent to Log followed by FailNow
	Fatalf(format string, args ...interface{})
}

TestingT is an interface to wrap the native *testing.T interface, this allows integration with GinkgoT() interface GinkgoT interface defined in https://github.com/onsi/ginkgo/blob/55c858784e51c26077949c81b6defb6b97b76944/ginkgo_dsl.go#L91

type Transport

type Transport struct {
	// contains filtered or unexported fields
}

Transport wraps components used to observe and manipulate the real request and response objects

func (*Transport) Hijack

func (r *Transport) Hijack()

Hijack replace the transport implementation of the interaction under test in order to observe, mock and inject expectations

func (*Transport) Reset

func (r *Transport) Reset()

Reset replace the hijacked transport implementation of the interaction under test to the original implementation

func (*Transport) RoundTrip

func (r *Transport) RoundTrip(req *http.Request) (mockResponse *http.Response, err error)

RoundTrip implementation intended to match a given expected mock request or throw an error with a list of reasons why no match was found.

type UnmatchedMock

type UnmatchedMock struct {
	URL url.URL
}

UnmatchedMock exposes some information about mocks that failed to match a request

type Verifier

type Verifier interface {
	Equal(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool
	True(t TestingT, value bool, msgAndArgs ...interface{}) bool
	JSONEq(t TestingT, expected string, actual string, msgAndArgs ...interface{}) bool
	Fail(t TestingT, failureMessage string, msgAndArgs ...interface{}) bool
	NoError(t TestingT, err error, msgAndArgs ...interface{}) bool
}

Verifier is the assertion interface allowing consumers to inject a custom assertion implementation. It also allows failure scenarios to be tested within spectest

Directories

Path Synopsis
cmd
spectest
Package main is a package that contains subcommands for the spectest CLI command.
Package main is a package that contains subcommands for the spectest CLI command.
spectest/sub
Package sub is spectest sub-commands.
Package sub is spectest sub-commands.
Package selector provides a set of functions for css selector based assertions
Package selector provides a set of functions for css selector based assertions
examples module
echo Module
fiber Module
gin Module
ginkgo Module
gorilla Module
graphql Module
httprouter Module
mocks Module
Package image provides assertions for image comparison.
Package image provides assertions for image comparison.
Package jsonpath is not referenced by user code.
Package jsonpath is not referenced by user code.
http
Package http is utility functions for http requests and responses.
Package http is utility functions for http requests and responses.
mocks
Package mocks provides convenience functions for asserting jsonpath expressions
Package mocks provides convenience functions for asserting jsonpath expressions
Package jsonschema provides a spectest.Assert function to validate the http response body against the provided json schema
Package jsonschema provides a spectest.Assert function to validate the http response body against the provided json schema
Package plantuml write plantuml markup to a writer
Package plantuml write plantuml markup to a writer
Package version manage spectest command version
Package version manage spectest command version
x
db
Package db provides a wrapper for database/sql to record SQL queries and results.
Package db provides a wrapper for database/sql to record SQL queries and results.

Jump to

Keyboard shortcuts

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