tests_utils

package
v3.2.5 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdaptRequest added in v3.0.26

func AdaptRequest(r HttpRequestComponents) http.Request

func JsonStr added in v3.0.26

func JsonStr[T any](obj *T) string

func JsonStrFromIoReadCloser added in v3.0.26

func JsonStrFromIoReadCloser(readCloser io.ReadCloser) string

func Make200Response added in v3.1.1

func Make200Response[T any](body *T) *http.Response

func MakeResponse added in v3.0.26

func MakeResponse(status int, body interface{}) *http.Response

func MakeResponseWithStatus added in v3.1.1

func MakeResponseWithStatus[T any](status int, body *T) *http.Response

func MockDoRequestNoBody added in v3.0.26

func MockDoRequestNoBody(httpRequester *mocks.HttpClientRequester, expectedRequest http.Request, res *http.Response, err error)

func MockDoRequestWithBody added in v3.0.26

func MockDoRequestWithBody[T any](mockRequest *MockRequestWithBodyParams[T])

func ParseReaderToStruct

func ParseReaderToStruct[T any](v io.Reader, t *T) error

func ParseStructToIoReadCloser

func ParseStructToIoReadCloser[T any](v *T) io.ReadCloser

func Pointer added in v3.0.32

func Pointer[T any](v T) *T

func RunGlideExternalApiTestCases added in v3.0.26

func RunGlideExternalApiTestCases[ResponseStructT any](
	t *testing.T,
	testCases []GlideExternalApiTestCase[ResponseStructT],
)

Types

type GlideExternalApiTestCase added in v3.0.26

type GlideExternalApiTestCase[T any] struct {
	Name                   string
	Arrange                func(client glide.Client)
	Act                    func(client glide.Client) (*T, error)
	ExpectedRequest        HttpRequestComponents
	MockResponse           *http.Response
	ErrorInsteadOfResponse error
	Assert                 func(*testing.T, *T, error)
}

type HttpRequestComponents added in v3.0.26

type HttpRequestComponents struct {
	Method string
	Url    string
	Body   interface{}
}

this type is mainly to keep the body an un-modified original struct

func MakeGetRequest added in v3.1.1

func MakeGetRequest(url string) HttpRequestComponents

func MakeRequest added in v3.0.26

func MakeRequest[T any](method string, url string, body *T) HttpRequestComponents

func MakeRequestWithNoBody added in v3.1.1

func MakeRequestWithNoBody(method string, url string) HttpRequestComponents

type MockRequestWithBodyParams added in v3.0.26

type MockRequestWithBodyParams[T any] struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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