test

package
v7.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2025 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package test contains utility code used in tests

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTimeFromString

func NewTimeFromString(t *testing.T, s string) time.Time

NewTimeFromString returns a time value parsed from a string in the RFC3339Nano format

Types

type XRateLimitHTTPHandler

type XRateLimitHTTPHandler struct {
	T           *testing.T
	SuccessCode int
	SuccessBody string
	// contains filtered or unexported fields
}

XRateLimitHTTPHandler first returns status 429 with the X-RateLimit-Next header set to time.Now() plus a random value between 1 and 5 milliseconds. It keeps sending 429 until the X-RateLimit-Next point in time. Then it starts to return SuccessCode and SuccessBody indefinitely.

func (*XRateLimitHTTPHandler) AvailableAt

func (h *XRateLimitHTTPHandler) AvailableAt() time.Time

AvailableAt returns the point in time at which the handler stops returning status code 429

func (*XRateLimitHTTPHandler) ReturnTimes

func (h *XRateLimitHTTPHandler) ReturnTimes() []time.Time

ReturnTimes returns a list of times at which subsequent responses were written

func (*XRateLimitHTTPHandler) ReturnedCodes

func (h *XRateLimitHTTPHandler) ReturnedCodes() []int

ReturnedCodes returns a list of status codes from subsequent handler responses

func (*XRateLimitHTTPHandler) ServeHTTP

Jump to

Keyboard shortcuts

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