clerktest

package
v2.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package clerktest provides utilities for testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateJWT

func GenerateJWT(t *testing.T, claims any, kid string) (string, crypto.PublicKey)

GenerateJWT creates a JSON web token with the provided claims and key ID.

Types

type Clock added in v2.0.3

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

Clock provides a test clock which can be manually advanced through time.

func NewClockAt added in v2.0.3

func NewClockAt(t time.Time) *Clock

NewClockAt returns a Clock initialized at the given time.

func (*Clock) Advance added in v2.0.3

func (c *Clock) Advance(d time.Duration)

Advance moves the test clock to a new point in time.

func (*Clock) Now added in v2.0.3

func (c *Clock) Now() time.Time

Now returns the clock's current time.

type RoundTripper

type RoundTripper struct {
	T *testing.T
	// Status is the response Status code.
	Status int
	// Out is the response body.
	Out json.RawMessage
	// Set this field to assert on the request method.
	Method string
	// Set this field to assert that the request path matches.
	Path string
	// Set this field to assert that the request URL querystring matches.
	Query *url.Values
	// Set this field to assert that the request body matches.
	In json.RawMessage
}

RoundTripper can be used as a mock Transport for http.Clients. Set the RoundTripper's fields accordingly to determine the response or perform assertions on the http.Request properties.

func (*RoundTripper) RoundTrip

func (rt *RoundTripper) RoundTrip(r *http.Request) (*http.Response, error)

RoundTrip returns an http.Response based on the RoundTripper's fields. It will also perform assertions on the http.Request.

Jump to

Keyboard shortcuts

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