aeinttest

package module
v0.0.0-...-3dc51f6 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2021 License: BSD-3-Clause Imports: 12 Imported by: 0

README

aeinttest

automated integration test library for the golang webservice projects deployed on Google appengine

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TestCase

type TestCase struct {
	Name             string
	RequestBody      string
	HttpVerb         string
	Uri              string
	WantStatusCode   int
	WantResponseBody string
	SkipFlag         bool
	//
	*testing.T
	context.Context
	http.Handler
}

func (TestCase) RunCase

func (tc TestCase) RunCase()

Method RunCase does same thing as RunCheckStatusCode. The major difference is that, instead of returning the (got) response body, RunCase compares the want response body with the got, and pass/fail the test case accordingly.

The order of elements in the json (between got and want) is not strict, however, all the fields in the want should exist in got (including the empty fields), and vice versa. otherwise the test fails.

func (TestCase) RunCheckStatusCode

func (tc TestCase) RunCheckStatusCode() (responseBody []byte)

Method RunCheckStatusCode, for the given test case record, invokes the call to the API on the given test server, compares want response status code to the got. This method doesn't check the response body, but will return the got response body to the caller. Caller is responsible to test for the response body. This limitation is helpful in situations where the response body cannot be directly tested, for example, if the response body contains undeterministic fields like created date, modified date. If that is not the case, use the RunCase() method instead.

type TestCases

type TestCases []TestCase

func (*TestCases) Load

func (tcs *TestCases) Load(filePath string, delim rune, hasHeader bool) error

Load method loads the given test cases data from the flat file into the TestCases slice object. If header is provided, will parse the data accordign the header, otherwise, the default order will be used.

Jump to

Keyboard shortcuts

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