tests_e2e

package
v1.4.6 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: MIT Imports: 20 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",
}
View Source
var JSON_HEADER http.Header = http.Header{
	"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 ApplicationOutputMatches added in v1.3.1

func ApplicationOutputMatches(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 interface{}](
	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 CreateTmpEnvironment added in v1.4.5

func CreateTmpEnvironment(entries ...FsEntry) string

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 Headers added in v1.4.6

func Headers(headerData ...string) http.Header

func HeadersMatch added in v0.2.0

func HeadersMatch(expectedHeaders http.Header) 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 MatchesFile added in v1.4.5

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

func MkTemp added in v1.4.5

func MkTemp(content []byte) string

func MkTempNamed added in v1.4.5

func MkTempNamed(fileName string, content []byte) string

func MockAssert

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

func Post added in v1.4.6

func Post(route string, headers http.Header, payload []byte) func(t *testing.T, response *Response, serverOutput []byte, state *E2eState)

func PostMultipart added in v1.4.6

func PostMultipart(route string, data map[string]string) func(t *testing.T, response *Response, serverOutput []byte, state *E2eState)

func PostUrlEncodedForm added in v1.4.6

func PostUrlEncodedForm(route string, data map[string]string) func(t *testing.T, response *Response, serverOutput []byte, state *E2eState)

func RemoveUntestableDataFromFileserverHtmlOutput added in v1.4.5

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

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 RunTest2 added in v1.4.5

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

func RunTest3 added in v1.4.6

func RunTest3(
	t *testing.T,
	args []string,
	request *TestRequest,
	assertionFunc ...func(t *testing.T, response *Response, serverOutput []byte, state *E2eState),
)

func RunTest4 added in v1.4.6

func RunTest4(
	t *testing.T,
	args []string,
	assertionFunc ...func(t *testing.T, response *Response, serverOutput []byte, state *E2eState),
)

func RunTestBase added in v0.6.0

func RunTestBase(
	t *testing.T,
	panicIfServerDidNotStart bool,
	configurationFilePath,
	extraArgs string,
	requests []TestRequest,
	env map[string]string,
	runMockOptions *RunMockOptions,
	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 RunTestWithNoConfigAndWithArgsFailing added in v1.3.1

func RunTestWithNoConfigAndWithArgsFailing(
	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)

func TidyUpHtmlResponse added in v1.4.5

func TidyUpHtmlResponse(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 FsEntry added in v1.4.5

type FsEntry struct {
	Dir         bool
	Name        string
	FileContent []byte
	Entries     []FsEntry
}

func DirEntry added in v1.4.5

func DirEntry(name string, entries []FsEntry) FsEntry

func FileEntry added in v1.4.5

func FileEntry(name string, content []byte) FsEntry

type KillMockFunc

type KillMockFunc func()

func RunMockBg

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

type Response added in v0.2.0

type Response struct {
	Body       []byte
	Headers    http.Header
	StatusCode int
}

func Request

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

type RunMockOptions added in v1.4.5

type RunMockOptions struct {
	Wd string
}

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