test

package
v0.0.0-...-580f94b Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package test implements utilities for testing

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertError

func AssertError(t *testing.T, err error, wantErr string)

AssertError asserts an error by checking if the `Error()` strings are equal

Types

type HandlerSet

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

HandlerSet is a struct with a mutex that allows us to swap handlers while a test server is running

func (*HandlerSet) ServeHTTP

func (hs *HandlerSet) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP serves HTTP using the handler

func (*HandlerSet) SetHandler

func (hs *HandlerSet) SetHandler(handler http.Handler)

SetHandler sets the handler to `handler`

type Server

type Server struct {
	*httptest.Server
}

Server wraps a HTTP test server

func NewServer

func NewServer(handler http.Handler) *Server

NewServer creates a new test server

func (*Server) Client

func (srv *Server) Client() (*httpw.Client, error)

Client returns a test client that trusts the HTTPS certificates

Jump to

Keyboard shortcuts

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