tests_e2e

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2023 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ContentTypeJsonHeaders map[string]string = map[string]string{
	"Content-type": "application/json",
}

Functions

func ApplicationOutputHasLines added in v1.0.0

func ApplicationOutputHasLines(expectedLines []string) func(t *testing.T, response *Response, serverOutput []byte, state *E2eState)

func AssertMapHasValues added in v0.2.0

func AssertMapHasValues[T_Key comparable, T_Value comparable](
	t *testing.T,
	subject map[T_Key]T_Value,
	values map[T_Key]T_Value,
)

func AssertTimeDifferenceEqualOrMoreThanSeconds added in v0.3.0

func AssertTimeDifferenceEqualOrMoreThanSeconds(t *testing.T, timeA, timeB time.Time, seconds int)

func AssertTimeDifferenceLessThanSeconds added in v0.3.0

func AssertTimeDifferenceLessThanSeconds(t *testing.T, timeA, timeB time.Time, seconds int)

func BuildFormPayload added in v0.8.1

func BuildFormPayload(data map[string]string) io.Reader

func EnvVarExists added in v1.0.0

func EnvVarExists(varName string) bool

func GetKeys added in v0.2.0

func GetKeys[T_Key comparable, T_Value interface{}](subject map[T_Key]T_Value) []T_Key

func HeaderKeysNotIncluded added in v0.5.0

func HeaderKeysNotIncluded(headerKeys []string) func(t *testing.T, response *Response, serverOutput []byte, state *E2eState)

func HeadersMatch added in v0.2.0

func HeadersMatch(expectedHeaders map[string]string) func(t *testing.T, response *Response, serverOutput []byte, state *E2eState)

func IndexOf added in v0.2.0

func IndexOf[T comparable](list []T, value T) int

func JsonMatches added in v0.1.0

func JsonMatches(expectedJson map[string]interface{}) func(t *testing.T, response *Response, serverOutput []byte, state *E2eState)

func LineEquals added in v0.2.0

func LineEquals(lineNumber int, expectedLine string) func(t *testing.T, response *Response, serverOutput []byte, state *E2eState)

func LineRegexMatches added in v0.2.0

func LineRegexMatches(lineNumber int, regex string) func(t *testing.T, response *Response, serverOutput []byte, state *E2eState)

func MockAssert

func MockAssert(assertOptions *mocklib.AssertOptions, serverOutput *bytes.Buffer, state *E2eState) []mocklib.ValidationError

func RequestApiReset added in v0.1.1

func RequestApiReset(config *mocklib.MockConfig)

func RunMock

func RunMock(state *E2eState, command string) ([]byte, error)

func RunTest added in v0.1.0

func RunTest(
	t *testing.T,
	configurationFilePath,
	method,
	route string,
	headers map[string]string,
	body io.Reader,
	assertionFunc ...func(t *testing.T, response *Response, serverOutput []byte, state *E2eState),
)

func RunTestBase added in v0.6.0

func RunTestBase(
	t *testing.T,
	configurationFilePath,
	extraArgs string,
	requests []TestRequest,
	env map[string]string,
	assertionFunc ...func(t *testing.T, response *Response, serverOutput []byte, state *E2eState),
)

func RunTestWithArgs added in v0.7.0

func RunTestWithArgs(
	t *testing.T,
	configurationFilePath string,
	args []string,
	method,
	route string,
	headers map[string]string,
	body io.Reader,
	assertionFunc ...func(t *testing.T, response *Response, serverOutput []byte, state *E2eState),
)

func RunTestWithArgsAndEnv added in v1.3.0

func RunTestWithArgsAndEnv(
	t *testing.T,
	args []string,
	method,
	route string,
	headers map[string]string,
	body io.Reader,
	env map[string]string,
	assertionFunc ...func(t *testing.T, response *Response, serverOutput []byte, state *E2eState),
)

func RunTestWithEnv added in v0.6.0

func RunTestWithEnv(
	t *testing.T,
	configurationFilePath,
	method,
	route string,
	headers map[string]string,
	body io.Reader,
	env map[string]string,
	assertionFunc ...func(t *testing.T, response *Response, serverOutput []byte, state *E2eState),
)

func RunTestWithJsonConfig added in v1.3.0

func RunTestWithJsonConfig(
	t *testing.T,
	jsonStr string,
	args []string,
	method,
	route string,
	headers map[string]string,
	body io.Reader,
	assertionFunc ...func(t *testing.T, response *Response, serverOutput []byte, state *E2eState),
)

func RunTestWithMultipleRequests added in v0.8.0

func RunTestWithMultipleRequests(
	t *testing.T,
	configurationFilePath string,
	requests []TestRequest,
	assertionFunc ...func(t *testing.T, response *Response, serverOutput []byte, state *E2eState),
)

func RunTestWithNoConfigAndWithArgs added in v0.7.0

func RunTestWithNoConfigAndWithArgs(
	t *testing.T,
	args []string,
	method,
	route string,
	headers map[string]string,
	body io.Reader,
	assertionFunc ...func(t *testing.T, response *Response, serverOutput []byte, state *E2eState),
)

func StatusCodeMatches added in v0.2.0

func StatusCodeMatches(expectedStatusCode int) func(t *testing.T, response *Response, serverOutput []byte, state *E2eState)

func StringMatches added in v0.1.0

func StringMatches(expected string) func(t *testing.T, response *Response, serverOutput []byte, state *E2eState)

Types

type E2eState

type E2eState struct {
	BinaryPath string
	Port       int
}

func NewState

func NewState() *E2eState

type KillMockFunc

type KillMockFunc func()

func RunMockBg

func RunMockBg(state *E2eState, command string, env map[string]string) (KillMockFunc, *bytes.Buffer, *mocklib.MockConfig)

type Response added in v0.2.0

type Response struct {
	Body       []byte
	Headers    map[string]string
	StatusCode int
}

func Request

func Request(config *mocklib.MockConfig, method, route string, payload io.Reader, headers map[string]string, serverOutput *bytes.Buffer) *Response

type TestRequest added in v0.8.0

type TestRequest struct {
	Method  string
	Route   string
	Headers map[string]string
	Body    io.Reader
}

func NewGetTestRequest added in v0.8.0

func NewGetTestRequest(route string) *TestRequest

func NewPostTestRequest added in v0.8.0

func NewPostTestRequest(route string) *TestRequest

Jump to

Keyboard shortcuts

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