http

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package http provides functionalities for mocking net/http components.

Index

Constants

View Source
const (
	// MethodGet is an alias of http.MethodGet.
	MethodGet = http.MethodGet
	// MethodPost is an alias of http.MethodPost.
	MethodPost = http.MethodPost

	// StatusOK is an lias of http.StatusOK.
	StatusOK = http.StatusOK
	// StatusCreated is an lias of http.StatusCreated.
	StatusCreated = http.StatusCreated
)

Variables

View Source
var NoMockResponseWriter = MockResponseWriter()

NoMockResponseWriter is no mock ResponseWriter.

Functions

func BuildRequest

func BuildRequest() *requestBuilder

BuildRequest builds a Request. nolint: revive

Types

type Header = http.Header

Header is an alias of http.Header.

type Request

type Request = http.Request

Request is an alias of http.Request.

type ResponseWriter

type ResponseWriter struct {
	mock.Mock
}

ResponseWriter is a http.ResponseWriter.

func (*ResponseWriter) Header

func (r *ResponseWriter) Header() http.Header

Header satisfies http.ResponseWriter interface.

func (*ResponseWriter) Write

func (r *ResponseWriter) Write(bytes []byte) (int, error)

Write satisfies http.ResponseWriter interface.

func (*ResponseWriter) WriteHeader

func (r *ResponseWriter) WriteHeader(statusCode int)

WriteHeader satisfies http.ResponseWriter interface.

type ResponseWriterMocker

type ResponseWriterMocker func(tb testing.TB) *ResponseWriter

ResponseWriterMocker is ResponseWriter mocker.

func MockResponseWriter

func MockResponseWriter(mocks ...func(w *ResponseWriter)) ResponseWriterMocker

MockResponseWriter creates ResponseWriter mock with cleanup to ensure all the expectations are met.

Jump to

Keyboard shortcuts

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