test

package
v2.12.3 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package test provides shared test utils

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenPoints added in v2.2.3

func GenPoints(num int) []*write.Point

GenPoints generates num points

func GenRecords added in v2.2.3

func GenRecords(num int) []string

GenRecords generates num points

Types

type HTTPService

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

HTTPService is http.Service implementation for tests

func NewTestService

func NewTestService(t *testing.T, serverURL string) *HTTPService

NewTestService creates new test HTTP service

func (*HTTPService) Authorization

func (t *HTTPService) Authorization() string

Authorization returns current authorization header value

func (*HTTPService) Close

func (t *HTTPService) Close()

Close clears instance

func (*HTTPService) DecodeLines added in v2.9.2

func (t *HTTPService) DecodeLines(body io.Reader) error

DecodeLines parses request body for lines

func (*HTTPService) DoHTTPRequest

DoHTTPRequest does nothing for this service

func (*HTTPService) DoHTTPRequestWithResponse

func (t *HTTPService) DoHTTPRequestWithResponse(_ *http.Request, _ http2.RequestCallback) (*http.Response, error)

DoHTTPRequestWithResponse does nothing for this service

func (*HTTPService) DoPostRequest

func (t *HTTPService) DoPostRequest(_ context.Context, url string, body io.Reader, requestCallback http2.RequestCallback, _ http2.ResponseCallback) *http2.Error

DoPostRequest reads http request, validates URL and stores data in the request

func (*HTTPService) GetRequest

GetRequest does nothing for this service

func (*HTTPService) HTTPClient

func (t *HTTPService) HTTPClient() *http.Client

HTTPClient returns nil for this service

func (*HTTPService) Lines

func (t *HTTPService) Lines() []string

Lines returns decoded lines from request

func (*HTTPService) ReplyError

func (t *HTTPService) ReplyError() *http2.Error

ReplyError returns current reply error

func (*HTTPService) Requests added in v2.10.0

func (t *HTTPService) Requests() int

Requests returns number of requests

func (*HTTPService) ServerAPIURL

func (t *HTTPService) ServerAPIURL() string

ServerAPIURL returns testing URL

func (*HTTPService) ServerURL

func (t *HTTPService) ServerURL() string

ServerURL returns testing URL

func (*HTTPService) SetAuthorization

func (t *HTTPService) SetAuthorization(_ string)

SetAuthorization sets authorization string

func (*HTTPService) SetReplyError

func (t *HTTPService) SetReplyError(replyError *http2.Error)

SetReplyError sets Error that will be returned as a response

func (*HTTPService) SetRequestHandler added in v2.9.2

func (t *HTTPService) SetRequestHandler(fn func(url string, body io.Reader) error)

SetRequestHandler sets custom handler for requests

func (*HTTPService) SetWasGzip

func (t *HTTPService) SetWasGzip(wasGzip bool)

SetWasGzip sets wasGzip flag

func (*HTTPService) WasGzip

func (t *HTTPService) WasGzip() bool

WasGzip returns true of request was in GZip format

Jump to

Keyboard shortcuts

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