chttptest

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2023 License: MIT Imports: 8 Imported by: 1

Documentation

Overview

Package chttptest provides utility functions that are useful when testing chttp

Index

Constants

View Source
const ContentTypeApplicationJSON = "application/json"

ContentTypeApplicationJSON defines the application/json content type that can be used when making HTTP requests.

Variables

View Source
var HTMLDir embed.FS

HTMLDir embeds a directory that can be used with chttp.ReaderWriter

Functions

func NewReaderWriter

func NewReaderWriter(t *testing.T) *chttp.ReaderWriter

NewReaderWriter creates a *chttp.ReaderWriter suitable for use in tests

func NewRouter

func NewRouter(routes []chttp.Route) chttp.Router

NewRouter returns a router that returns the given routes.

func PingRoutes

func PingRoutes(t *testing.T, routes []chttp.Route)

PingRoutes creates a handler using chttp.NewHandler, starts a test http server, and calls each provided route. It verifies that each route's handler is called successfully.

func ReverseRoutes

func ReverseRoutes(routes []chttp.Route) []chttp.Route

ReverseRoutes reverses the provided slice of chttp.Route.

Types

This section is empty.

Jump to

Keyboard shortcuts

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