tape

package
v0.0.0-...-0985497 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildDataRequest

func BuildDataRequest(method, url string, data map[string]interface{}) *http.Request

BuildDataRequest creates a request

func CreateFileRequestBody

func CreateFileRequestBody(path, contentType string, params map[string]string) (*bytes.Buffer, string, error)

CreateFileRequestBody create a multi-part form data. We assume all endpoints handling files are receicing a single file with form name "file_data"

func ToH

func ToH(z interface{}) map[string]interface{}

ToH is a convenience wrapper create a json for any object

Types

type RequestModifier

type RequestModifier interface {
	Modify(r *http.Request)
}

type Tape

type Tape struct {
	Router *chi.Mux
}

Tape can send requests to router endpoints. This is used by unit tests to check the endpoints

func NewTape

func NewTape() *Tape

NewTape creates a new Tape

func (*Tape) Delete

func (t *Tape) Delete(url string, modifiers ...RequestModifier) *httptest.ResponseRecorder

Delete creates, sends a DELETE request and fetches the response

func (*Tape) FormatRequest

func (t *Tape) FormatRequest(r *http.Request) string

FormatRequest pretty-formats a request and returns it as a string

func (*Tape) Get

func (t *Tape) Get(url string, modifiers ...RequestModifier) *httptest.ResponseRecorder

Get creates, sends a GET request and fetches the response

func (*Tape) Patch

func (t *Tape) Patch(url string, data map[string]interface{}, modifiers ...RequestModifier) *httptest.ResponseRecorder

Patch creates, sends a PATCH request and fetches the response

func (*Tape) PlayRequest

func (t *Tape) PlayRequest(r *http.Request) *httptest.ResponseRecorder

PlayRequest will send the request to the router and fetch the response

func (*Tape) Post

func (t *Tape) Post(url string, data map[string]interface{}, modifiers ...RequestModifier) *httptest.ResponseRecorder

Post creates, sends a POST request and fetches the response

func (*Tape) Put

func (t *Tape) Put(url string, data map[string]interface{}, modifiers ...RequestModifier) *httptest.ResponseRecorder

Put creates, sends a PUT request and fetches the response

func (*Tape) ToH

func (t *Tape) ToH(z interface{}) map[string]interface{}

ToH is a convenience wrapper create a json for any object

func (*Tape) Upload

func (t *Tape) Upload(url string, filename string, contentType string, modifiers ...RequestModifier) (*httptest.ResponseRecorder, error)

func (*Tape) UploadWithParameters

func (t *Tape) UploadWithParameters(url string, filename string, contentType string, params map[string]string, modifiers ...RequestModifier) (*httptest.ResponseRecorder, error)

Jump to

Keyboard shortcuts

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