package module
v0.3.0-beta Latest Latest

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

Go to latest
Published: Mar 24, 2021 License: MIT Imports: 25 Imported by: 0



Api-Master is a library that makes it easier to write end-to-end HTTP and Rest API testing for Go.

Basically, it provides a set of chain methods to write tests.




View Source
const (
	EnvironmentKey         = "API_MASTER_ENV"
	EnvironmentFilePathKey = "API_MASTER_ENV_FILE_PATH"

	EnvironmentFilePrefix      = "env"
	EnvironmentFileType        = "yaml"
	DefaultEnvironmentFilePath = "."
View Source
const (
	ContentTypeApplicationJson = "application/json"
	ContentTypeApplicationXml  = "application/xml"
	ContentTypeTextPlain       = "text/plain"
View Source
const HeaderContentType = "Content-Type"


This section is empty.


This section is empty.


type Client

type Client struct {
	// contains filtered or unexported fields

func NewClient

func NewClient(t *testing.T) *Client

func (*Client) CONNECT

func (client *Client) CONNECT(url string) *Request

func (*Client) CleanAllCookies

func (client *Client) CleanAllCookies() *Client

func (*Client) DELETE

func (client *Client) DELETE(url string) *Request

func (*Client) GET

func (client *Client) GET(url string) *Request

func (*Client) GetContext

func (client *Client) GetContext() *context.Context

func (*Client) GetCookies

func (client *Client) GetCookies(u *url.URL) []*http.Cookie

func (*Client) HEAD

func (client *Client) HEAD(url string) *Request

func (*Client) OPTIONS

func (client *Client) OPTIONS(url string) *Request

func (*Client) PATCH

func (client *Client) PATCH(url string) *Request

func (*Client) POST

func (client *Client) POST(url string) *Request

func (*Client) PUT

func (client *Client) PUT(url string) *Request

func (*Client) TRACE

func (client *Client) TRACE(url string) *Request

type Environment

type Environment struct {

func GetEnvironment

func GetEnvironment() *Environment

func (*Environment) Get

func (environment *Environment) Get(key string) interface{}

func (*Environment) GetBool

func (environment *Environment) GetBool(key string) bool

func (*Environment) GetDuration

func (environment *Environment) GetDuration(key string) time.Duration

func (*Environment) GetFloat64

func (environment *Environment) GetFloat64(key string) float64

func (*Environment) GetInt

func (environment *Environment) GetInt(key string) int

func (*Environment) GetInt32

func (environment *Environment) GetInt32(key string) int32

func (*Environment) GetInt64

func (environment *Environment) GetInt64(key string) int64

func (*Environment) GetIntSlice

func (environment *Environment) GetIntSlice(key string) []int

func (*Environment) GetString

func (environment *Environment) GetString(key string) string

func (*Environment) GetStringMap

func (environment *Environment) GetStringMap(key string) map[string]interface{}

func (*Environment) GetStringSlice

func (environment *Environment) GetStringSlice(key string) []string

func (*Environment) GetTime

func (environment *Environment) GetTime(key string) time.Time

func (*Environment) GetUint

func (environment *Environment) GetUint(key string) uint

func (*Environment) GetUint32

func (environment *Environment) GetUint32(key string) uint32

func (*Environment) GetUint64

func (environment *Environment) GetUint64(key string) uint64

type Request

type Request struct {
	// contains filtered or unexported fields

func (*Request) Expect

func (r *Request) Expect() *Response

func (*Request) WithBody

func (r *Request) WithBody(value []byte) *Request

func (*Request) WithCookie

func (r *Request) WithCookie(cookie *http.Cookie) *Request

func (*Request) WithHeader

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

func (*Request) WithHeaders

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

func (*Request) WithJson

func (r *Request) WithJson(object interface{}) *Request

func (*Request) WithPathVariable

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

func (*Request) WithRequestParameter

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

func (*Request) WithText

func (r *Request) WithText(text string) *Request

func (*Request) WithXml

func (r *Request) WithXml(object interface{}) *Request

type Response

type Response struct {
	// contains filtered or unexported fields

func (*Response) Body

func (r *Response) Body(expects ...body.Expect) *ResponseQuery

func (*Response) ContentLength

func (r *Response) ContentLength(expects ...clength.Expect) *Response

func (*Response) ContentType

func (r *Response) ContentType(expects ...ctype.Expect) *Response

func (*Response) ElapsedTime

func (r *Response) ElapsedTime(expects ...duration.Expect) *Response

func (*Response) Header

func (r *Response) Header(expects ...header.Expect) *Response

func (*Response) Headers

func (r *Response) Headers(expects ...headers.Expect) *Response

func (*Response) Raw

func (r *Response) Raw() *http.Response

func (*Response) Status

func (r *Response) Status(expects ...status.Expect) *Response

type ResponseQuery

type ResponseQuery struct {
	// contains filtered or unexported fields

func (*ResponseQuery) JsonQuery

func (responseQuery *ResponseQuery) JsonQuery() *jsonq.JsonQuery

func (*ResponseQuery) StringQuery

func (responseQuery *ResponseQuery) StringQuery() *stringq.StringQuery


Path Synopsis

Jump to

Keyboard shortcuts

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