testutils

package
v1.1.1-0...-bedd7c6 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get(url string, opts ...ReqOption) (*http.Response, []byte, error)

Get do a GET request

func GetClock

func GetClock() *timetools.FreezedTime

GetClock gets a FreezedTime

func MakeRequest

func MakeRequest(url string, opts ...ReqOption) (*http.Response, []byte, error)

MakeRequest create and do a request

func NewHandler

func NewHandler(handler http.HandlerFunc) *httptest.Server

NewHandler creates a new Server

func NewResponder

func NewResponder(response string) *httptest.Server

NewResponder creates a new Server with response

func ParseURI

func ParseURI(uri string) *url.URL

ParseURI is the version of url.ParseRequestURI that panics if incorrect, helpful to shorten the tests

func Post

func Post(url string, opts ...ReqOption) (*http.Response, []byte, error)

Post do a POST request

Types

type ReqOption

type ReqOption func(o *ReqOpts) error

ReqOption request option type

func BasicAuth

func BasicAuth(username, password string) ReqOption

BasicAuth sets request basic auth

func Body

func Body(b string) ReqOption

Body sets request body

func Header(name, val string) ReqOption

Header sets request header

func Headers

func Headers(h http.Header) ReqOption

Headers sets request headers

func Host

func Host(h string) ReqOption

Host sets request host

func Method

func Method(m string) ReqOption

Method sets request method

type ReqOpts

type ReqOpts struct {
	Host    string
	Method  string
	Body    string
	Headers http.Header
	Auth    *utils.BasicAuth
}

ReqOpts request options

Jump to

Keyboard shortcuts

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