internal

package
v0.0.0-...-10dc7e0 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2020 License: MPL-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTestClient

func NewTestClient(transport http.RoundTripper) *http.Client

NewTestClient returns *http.Client with Transport replaced to avoid making real calls

func Return200

func Return200(req *http.Request) (*http.Response, error)

Return200 returns an http response with a dummy body and statuscode 200

Types

type FakeMailer

type FakeMailer struct {
	Num911Sent         int
	NumEscalationsSent int
	ArgList911callers  []string
	ArgList911messages []string
}

FakeMailer is a mock for the escalation mailer

func (*FakeMailer) DefaultEscalationEmail

func (f *FakeMailer) DefaultEscalationEmail() string

DefaultEscalationEmail returns the email address of the fake emailer

func (*FakeMailer) Send911Email

func (f *FakeMailer) Send911Email(caller string, message string) error

Send911Email records the 911 escalation emails we've sent out

func (*FakeMailer) SendEscalationEmail

func (f *FakeMailer) SendEscalationEmail(alert *common.Alert) error

SendEscalationEmail simply increments an internal counter of how many escalations we've sent

type FakeTransport

type FakeTransport struct {
	RequestURLs []string
	// contains filtered or unexported fields
}

FakeTransport is a roundtripper that can used with httpclient to write unit tests

func NewFakeTransport

func NewFakeTransport() *FakeTransport

NewFakeTransport creates a faketransport that default returns 200s

func (*FakeTransport) AddHandler

func (f *FakeTransport) AddHandler(url string, handler interface{})

AddHandler installs a handler for a specific url

func (*FakeTransport) RoundTrip

func (f *FakeTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip .

Jump to

Keyboard shortcuts

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