helpers

package
v0.0.0-...-7eda018 Latest Latest
Warning

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

Go to latest
Published: May 30, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetupTestDatabase

func SetupTestDatabase(t *testing.T) *gorm.DB

Types

type ErroringRoundTripFunc

type ErroringRoundTripFunc func() error

ErroringRoundTripFunc Needed to Mock Http client that returns an error even before the request is made

Usage

&http.Client{
	 Transport: helpers.ErroringRoundTripFunc(func() error {
	 	return fmt.Errorf("some error")
	 }),
}

func (ErroringRoundTripFunc) RoundTrip

func (f ErroringRoundTripFunc) RoundTrip(req *http.Request) (*http.Response, error)

ErroringRoundTripFunc implements the RoundTripper interface

type RoundTripFunc

type RoundTripFunc func(req *http.Request) *http.Response

RoundTripFunc Needed to Mock Http client requests and responses

Usage

&http.Client{
	 Transport: helpers.RoundTripFunc(func(req *http.Request) *http.Response {
	    bodyBytes, _ := ioutil.ReadAll(req.Body)

	 	suite.EqualValues(expectedBody, string(bodyBytes))

	 	suite.Equal(req.URL.String(), expectedUrl)
	 	return &http.Response{
			StatusCode: returnedStatusCode,
	 	}
    }),
}

func (RoundTripFunc) RoundTrip

func (f RoundTripFunc) RoundTrip(req *http.Request) (*http.Response, error)

RoundTripFunc implements the RoundTripper interface

Jump to

Keyboard shortcuts

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