apitest

package
v0.1.0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: May 31, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

go:build test

go:build test

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertAPIResourcesEqual

func AssertAPIResourcesEqual(t *testing.T, exp *types.APIResourceMeta, got *types.APIResourceMeta)

func AssertResponseError

func AssertResponseError(t *testing.T, rr *httptest.ResponseRecorder, statusCode int, expReqErr *types.APIErrors)

func AssertResponseExpected

func AssertResponseExpected(t *testing.T, rr *httptest.ResponseRecorder, statusCode int, expResponse interface{}, gotTarget interface{})

func AssertResponseForbidden

func AssertResponseForbidden(t *testing.T, rr *httptest.ResponseRecorder)

func AssertResponseInternalServerError

func AssertResponseInternalServerError(t *testing.T, rr *httptest.ResponseRecorder)

func AssertStatusCode

func AssertStatusCode(t *testing.T, rr *httptest.ResponseRecorder, statusCode int)

func RunAPITest

func RunAPITest(t *testing.T, test APITestFunc, opts *APITesterOpts, initMethods ...testutils.InitDataFunc)

Types

type APITestFunc

type APITestFunc func(config *server.Config, rr *httptest.ResponseRecorder, req *http.Request) error

type APITester

type APITester struct {
	// contains filtered or unexported fields
}

type APITesterOpts

type APITesterOpts struct {
	Method, Route  string
	RequestObj     interface{}
	HandlerInit    HandlerInitFunc
	CtxGenerators  []GenerateRequestCtx
	URLGenerators  []GenerateURLParam
	BodyGenerators []GenerateBodyParam
}

type HandlerInitFunc

type HandlerInitFunc func(
	config *server.Config,
	decoderValidator handlerutils.RequestDecoderValidator,
	writer handlerutils.ResultWriter,
) http.Handler

Jump to

Keyboard shortcuts

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