testserver

package
v0.67.2 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2021 License: MIT Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TestServer

type TestServer struct {
	Port int
	// contains filtered or unexported fields
}

TestServer wraps a http.Server that runs on a separate goroutine and is intended for unit testing.

func CreateAndStart

func CreateAndStart(port int, mux *http.ServeMux) (*TestServer, error)

CreateAndStart creates and returns a TestServer that waits for web requests on the provided port using the provided multiplexer on a different goroutine.

If the port is 0, a port number is dynamically chosen. This port can be retrieved by checking the Port field of the TestServer struct.

func (TestServer) Stop

func (ms TestServer) Stop()

Stop immediately closes all connections and shuts down the server.

Jump to

Keyboard shortcuts

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