testutils

package
v0.0.0-...-857ab11 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateTempZip

func CreateTempZip(filenameInZip, content string) (string, error)

CreateTempZip creates a zip file that contains a file

func GenerateInvalidURL

func GenerateInvalidURL() string

GenerateInvalidURL provides random invalid URL

func TouchTempFile

func TouchTempFile() (string, error)

TouchTempFile creates a temporary file

Types

type ErrorWriter

type ErrorWriter struct {
	// contains filtered or unexported fields
}

ErrorWriter helps error handling while writing.

func NewErrorWriter

func NewErrorWriter(w io.Writer, err error) ErrorWriter

NewErrorWriter creates a ErrorWriter instance.

func (ErrorWriter) Err

func (w ErrorWriter) Err() error

Err returns error if any error occurred in Write method.

func (ErrorWriter) Write

func (w ErrorWriter) Write(p []byte) (n int, err error)

Write writes only if no error occurred.

type FailBodyHTTPClient

type FailBodyHTTPClient struct {
	Err error
}

FailBodyHTTPClient helps simulating failure on reading response body.

func (*FailBodyHTTPClient) Get

func (c *FailBodyHTTPClient) Get(url string) (resp *http.Response, err error)

Get returns response which returns error while reading.

type TestServerHandler

type TestServerHandler struct {
	StatusCode int
	Content    string
}

TestServerHandler is a handler that returns specified contents for tests

func (TestServerHandler) ServeHTTP

func (h TestServerHandler) ServeHTTP(writer http.ResponseWriter, request *http.Request)

ServeHTTP returns specified contents in TestServerHandler

Jump to

Keyboard shortcuts

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