test

package
v9.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2024 License: Apache-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. Note that it cuts off trailing zeros in the milliseconds part, which might cause issues in IAM endpoints which do not accept the time format without the milliseconds part.

Example: if "2025-10-11T23:06:59.000Z" is used, the actual value that will be sent is "2025-10-11T23:06:59Z".

Types

type XRateLimitHTTPHandler added in v9.1.0

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 added in v9.1.0

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

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

func (*XRateLimitHTTPHandler) ReturnTimes added in v9.1.0

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

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

func (*XRateLimitHTTPHandler) ReturnedCodes added in v9.1.0

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

ReturnedCodes returns a list of status codes from subsequent handler responses

func (*XRateLimitHTTPHandler) ServeHTTP added in v9.1.0

Jump to

Keyboard shortcuts

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