routetest

package module
v0.0.0-...-dc0cab0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2024 License: MIT Imports: 8 Imported by: 0

README

routetest

With routetest you can be sure that every signle route in your application is tested.

This package contains middlewares for popular Go HTTP routers like std http, chi, echo, gin.

See tests for usage examples.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChiV5Reporter

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

ChiV5Reporter tracks visited routes of chi router. It is used to check if all routes have been tested.

func NewChiV5Reporter

func NewChiV5Reporter() *ChiV5Reporter

NewChiV5Reporter creates a new chi reporter.

func (*ChiV5Reporter) Register

func (rep *ChiV5Reporter) Register(router chi.Router)

Register registers chi router for testing.

func (*ChiV5Reporter) Report

func (rep *ChiV5Reporter) Report() Report

Report returns a report of visited routes.

func (*ChiV5Reporter) Visitor

func (rep *ChiV5Reporter) Visitor(next http.Handler) http.Handler

Visitor is a middleware that tracks visited routes.

type EchoV4Reporter

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

EchoV4Reporter tracks visited routes of echo router. It is used to check if all routes have been tested.

func NewEchoV4Reporter

func NewEchoV4Reporter() *EchoV4Reporter

NewReporter creates a new echo reporter.

func (*EchoV4Reporter) Register

func (rep *EchoV4Reporter) Register(router *echo.Echo)

Register registers echo router for testing.

func (*EchoV4Reporter) Report

func (rep *EchoV4Reporter) Report() Report

Report returns a report of visited routes.

func (*EchoV4Reporter) Visitor

func (rep *EchoV4Reporter) Visitor(next echo.HandlerFunc) echo.HandlerFunc

Visitor is a middleware that tracks visited routes.

type GinReporter

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

GinReporter tracks visited routes of gin router. It is used to check if all routes have been tested.

func NewGinReporter

func NewGinReporter() *GinReporter

NewGinReporter creates a new gin reporter.

func (*GinReporter) Register

func (rep *GinReporter) Register(engine *gin.Engine)

Register registers gin router for testing.

func (*GinReporter) Report

func (rep *GinReporter) Report() Report

Report returns a report of visited routes.

func (*GinReporter) Visitor

func (rep *GinReporter) Visitor(ctx *gin.Context)

Visitor is a middleware that tracks visited routes.

type Report

type Report struct {
	Total  int
	Tested int
	Missed int

	MissedRoutes []string
}

Report is a report of visited routes.

func (Report) String

func (r Report) String() string

String returns a string representation of the report.

func (Report) Success

func (r Report) Success() bool

Success returns true if all routes have been tested.

type StdHttpReporter

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

StdHttpReporter tracks visited routes of std http router. It is used to check if all routes have been tested.

func NewStdHttpReporter

func NewStdHttpReporter() *StdHttpReporter

NewStdHttpReporter creates a new std http reporter.

func (*StdHttpReporter) Register

func (rep *StdHttpReporter) Register(pattern string)

Register registers std http router for testing.

func (*StdHttpReporter) Report

func (rep *StdHttpReporter) Report() Report

Report returns a report of visited routes.

func (*StdHttpReporter) Visitor

func (rep *StdHttpReporter) Visitor(next http.Handler) http.Handler

Visitor is a middleware that tracks visited routes.

Jump to

Keyboard shortcuts

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