testutils

package
v0.25.1 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2019 License: AGPL-3.0 Imports: 26 Imported by: 0

Documentation

Overview

Package testutils is indended only for use in tests, do not import in production code!

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTLSClientConfig

func GetTLSClientConfig(t testing.TB, srv *httptest.Server) *tls.Config

GetTLSClientConfig returns a TLS config that trusts the supplied httptest.Server certificate as well as all the system root certificates

Types

type HTTPMultiBin

type HTTPMultiBin struct {
	Mux             *http.ServeMux
	ServerHTTP      *httptest.Server
	ServerHTTPS     *httptest.Server
	Replacer        *strings.Replacer
	TLSClientConfig *tls.Config
	Dialer          *netext.Dialer
	HTTPTransport   *http.Transport
	Context         context.Context
	Cleanup         func()
}

HTTPMultiBin can be used as a local alternative of httpbin.org. It offers both http and https servers, as well as real domains

func NewHTTPMultiBin

func NewHTTPMultiBin(t testing.TB) *HTTPMultiBin

NewHTTPMultiBin returns a fully configured and running HTTPMultiBin

type SimpleLogrusHook added in v0.24.0

type SimpleLogrusHook struct {
	HookedLevels []log.Level
	// contains filtered or unexported fields
}

SimpleLogrusHook implements the logrus.Hook interface and could be used to check if log messages were outputted

func (*SimpleLogrusHook) Drain added in v0.24.0

func (smh *SimpleLogrusHook) Drain() []log.Entry

Drain returns the currently stored messages and deletes them from the cache

func (*SimpleLogrusHook) Fire added in v0.24.0

func (smh *SimpleLogrusHook) Fire(e *log.Entry) error

Fire saves whatever message the logrus library passed in the cache

func (*SimpleLogrusHook) Levels added in v0.24.0

func (smh *SimpleLogrusHook) Levels() []log.Level

Levels just returns whatever was stored in the HookedLevels slice

Jump to

Keyboard shortcuts

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