integration

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateProfile

func CreateProfile(name string, content string)

CreateProfile creates a profile file with the specified content in the current test profile directory

func ExecuteCommand

func ExecuteCommand(cmd string, args ...string) (int, string, string, error)

ExecuteCommand executes an external command and wait for the command to finish executing

func HasBody

func HasBody(t *testing.T, req Request, body string)

HasBody asserts that the request received the specified body

func HasCookie

func HasCookie(t *testing.T, req Request, name string, value string)

HasCookie asserts that the request received the specific cookies

func HasHeader

func HasHeader(t *testing.T, req Request, name string, value string)

HasHeader asserts that the rquest received the specified header with value

func HasMethod

func HasMethod(t *testing.T, req Request, method string)

HasMethod asserts that the request received the specified method

func HasPath

func HasPath(t *testing.T, req Request, expectedPath string)

HasPath asserts that the request received the specified path

func HasQueryParam

func HasQueryParam(t *testing.T, req Request, name string, value string)

HasQueryParam checks if a request has the query parameter with the specified value

func HasRequestCount

func HasRequestCount(t *testing.T, expectedCount int)

HasRequestCount checks if the number of requests executed so far is the expected

func KillDaemon

func KillDaemon()

KillDaemon runs the kill daemon command

func RunHTTP

func RunHTTP(t *testing.T, args ...string) string

RunHTTP will run the http CLI with the specified arguments, ensure that it finished correctly and return the output

func WithTempFile

func WithTempFile(t *testing.T, content string, toWrap func(*os.File))

WithTempFile creates a temporary file, write content to it and then call the wrapped function

func WrapForIntegrationTest

func WrapForIntegrationTest(toWrap func(*testing.T)) func(*testing.T)

WrapForIntegrationTest wraps a testing function with all the required pieces for an integration test

func WrapWithKillDamon

func WrapWithKillDamon(toWrap func(*testing.T)) func(*testing.T)

WrapWithKillDamon executes a test after calling KillDaemon

func WrapWithTestServer

func WrapWithTestServer(toWrap func(*testing.T)) func(*testing.T)

WrapWithTestServer initializes the test server and make sure it will tear down correctly after

Types

type ReplyWith

type ReplyWith struct {
	Headers map[string][]string
	Body    string
}

ReplyWith gives specifications the ability to ask the server to reply in a specific way

type Request

type Request struct {
	Body    string
	Cookies []*http.Cookie
	Headers map[string][]string
	Method  string
	Path    string
	Query   map[string][]string
}

Request stores a request that was received by the test server

Jump to

Keyboard shortcuts

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