fakeserver

package
v0.0.0-...-19a1b97 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package fakeserver provides a fake HTTP server for testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FakeServer

type FakeServer struct {

	// Reqs contain the requests made to the server, in order.
	Reqs []*http.Request

	// Resps will be returned in order when calls are made to the server.
	Resps []string
	// contains filtered or unexported fields
}

FakeServer contains a fake HTTP server for testing.

func New

func New() *FakeServer

New creates a new FakeServer for testing.

func (*FakeServer) AddOnClose

func (s *FakeServer) AddOnClose(f func())

AddOnClose adds a function to be run when Close() is called.

func (*FakeServer) Close

func (s *FakeServer) Close()

Close closes the server and calls functions registered by AddOnClose()

func (*FakeServer) Reset

func (s *FakeServer) Reset()

Reset resets the server's response to its default.

func (*FakeServer) URL

func (s *FakeServer) URL(t testing.TB) *url.URL

URL returns the server's URL.

Jump to

Keyboard shortcuts

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