infra

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Copyright 2020 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0

Index

Constants

This section is empty.

Variables

View Source
var ErrorResponse = http.Response{
	StatusCode: http.StatusInternalServerError,
	Body:       ioutil.NopCloser(bytes.NewReader([]byte(errorBody))),
}

ErrorResponse simulates an error response.

Functions

func AcceptedResponse

func AcceptedResponse(pluginId string, lastDeltaId int) http.Response

AcceptedResponse creates a mock http.Response with a StatusAccepted code.

func ResetDeltasResponse

func ResetDeltasResponse(pluginId string) http.Response

func TooManyRequestsResponse

func TooManyRequestsResponse(opts ...ResponseOption) http.Response

TooManyRequestsResponse creates a mock http.Response with a StatusTooManyRequests code.

Types

type RequestRecorderClient

type RequestRecorderClient struct {
	Client    backendhttp.Client
	RequestCh chan http.Request
}

RequestRecorderClient is an HTTP client that records the first arriving request.

func NewRequestRecorderClient

func NewRequestRecorderClient(responses ...http.Response) *RequestRecorderClient

NewRequestRecorderClient creates a new RequestRecorderClient, passing the expected responses in order of invocation. If all the responses are returned or no responses are passed, it always returns "202 Status Accepted".

type ResponseOption

type ResponseOption = func(http.Response)

func RetryAfter

func RetryAfter(value string) ResponseOption

RetryAfter adds the `Retry-After` header to the HTTP response.

Jump to

Keyboard shortcuts

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