testhelpers

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckAPITestCaseResult

func CheckAPITestCaseResult(tt TestCase, res *httptest.ResponseRecorder, t *testing.T)

CheckAPITestCaseResult - Check API TestCase's result

func CheckAPITestCases

func CheckAPITestCases(
	tests []TestCase,
	getRequest GetAPIRequestFunc,
	t *testing.T,
	handler http.Handler,
)

CheckAPITestCases - Check API test Cases

func CheckGRPCTestCaseResult

func CheckGRPCTestCaseResult(
	testCase TestCase,
	got interface{},
	err error,
	t *testing.T,
)

CheckGRPCTestCaseResult - check single GRPC test result

func CheckGRPCTestCases

func CheckGRPCTestCases(
	testCases []TestCase,
	getGrpcResult GetGRPCResultFunc,
	t *testing.T,
)

CheckGRPCTestCases - check multiple GRPC test cases

func DeepEqualJSON

func DeepEqualJSON(xJSON, yJSON string, ignoredKeys []string) bool

DeepEqualJSON - check if two json string are equal, with ignoredKeys

func JSONMustMarshal

func JSONMustMarshal(val interface{}) string

JSONMustMarshal - direct json.Marshal with ignore errors

Types

type GetAPIRequestFunc

type GetAPIRequestFunc func(interface{}) *http.Request

GetAPIRequestFunc -

type GetGRPCResultFunc

type GetGRPCResultFunc func(TestCase, *testing.T) (interface{}, error)

GetGRPCResultFunc -

type TestCase

type TestCase struct {
	App              *gobay.Application
	Ctx              context.Context
	Name             string
	Req              interface{}
	IgnoredFieldKeys []string
	WantJSON         string
	WantErr          bool
	WantStatusCode   int
}

TestCase - test case

func MakeTestCase

func MakeTestCase(query *TestCase, wantRes interface{}) TestCase

MakeTestCase - auto-fix test case if

Jump to

Keyboard shortcuts

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