tests_utils

package
v4.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2022 License: MIT Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdaptRequest

func AdaptRequest(r HttpRequestComponents) http.Request

func JsonStr

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

func JsonStrFromIoReadCloser

func JsonStrFromIoReadCloser(readCloser io.ReadCloser) string

func Make200Response

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

func MakeResponse

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

func MakeResponseWithStatus

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

func MockDoRequestNoBody

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

func MockDoRequestWithBody

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

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

func RunGlideExternalApiTestCases

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

Types

type GlideExternalApiTestCase

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

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

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

func MakeGetRequest

func MakeGetRequest(url string) HttpRequestComponents

func MakeRequest

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

func MakeRequestWithNoBody

func MakeRequestWithNoBody(method string, url string) HttpRequestComponents

type MockRequestWithBodyParams

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