mocks

package
v0.0.0-...-4f04cd8 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2015 License: MPL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LogMessage

type LogMessage struct {
	Priority syslog.Priority // aka Log level
	Message  string          // content of log message
}

LogMessage is a log entry that has been sent to a MockSyslogWriter.

func (*LogMessage) String

func (lm *LogMessage) String() string

type MockCADatabase

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

MockCADatabase is a mock

func NewMockCertificateAuthorityDatabase

func NewMockCertificateAuthorityDatabase() (mock *MockCADatabase, err error)

NewMockCertificateAuthorityDatabase is a mock

func (*MockCADatabase) Begin

func (cadb *MockCADatabase) Begin() (*gorp.Transaction, error)

Begin is a mock

func (*MockCADatabase) CreateTablesIfNotExists

func (cadb *MockCADatabase) CreateTablesIfNotExists() error

CreateTablesIfNotExists is a mock

func (*MockCADatabase) IncrementAndGetSerial

func (cadb *MockCADatabase) IncrementAndGetSerial(*gorp.Transaction) (int64, error)

IncrementAndGetSerial is a mock

type MockDNS

type MockDNS struct {
}

MockDNS is a mock

func (*MockDNS) ExchangeOne

func (mock *MockDNS) ExchangeOne(hostname string, qt uint16) (rsp *dns.Msg, rtt time.Duration, err error)

ExchangeOne is a mock

func (*MockDNS) LookupCAA

func (mock *MockDNS) LookupCAA(domain string) ([]*dns.CAA, time.Duration, error)

LookupCAA is a mock

func (*MockDNS) LookupCNAME

func (mock *MockDNS) LookupCNAME(domain string) (string, time.Duration, error)

LookupCNAME is a mock

func (*MockDNS) LookupDNAME

func (mock *MockDNS) LookupDNAME(domain string) (string, time.Duration, error)

LookupDNAME is a mock

func (*MockDNS) LookupHost

func (mock *MockDNS) LookupHost(hostname string) ([]net.IP, time.Duration, time.Duration, error)

LookupHost is a mock

func (*MockDNS) LookupMX

func (mock *MockDNS) LookupMX(domain string) ([]string, time.Duration, error)

LookupMX is a mock

func (*MockDNS) LookupTXT

func (mock *MockDNS) LookupTXT(hostname string) ([]string, time.Duration, error)

LookupTXT is a mock

type MockSyslogWriter

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

MockSyslogWriter implements the blog.SyslogWriter interface. It stores all logged messages in a buffer for inspection by test functions (via GetAll()) instead of sending them to syslog.

func NewSyslogWriter

func NewSyslogWriter() *MockSyslogWriter

NewSyslogWriter returns a new MockSyslogWriter.

func UseMockLog

func UseMockLog() *MockSyslogWriter

UseMockLog changes the SyslogWriter used by the current singleton audit logger to a new mock logger, and returns the mock. Example:

var log = mocks.UseMockLog()
func TestFoo(t *testing.T) {
	log.Clear()
	// ...
	Assert(t, len(log.GetAll()) > 0, "Should have logged something")
}

func (*MockSyslogWriter) Alert

func (msw *MockSyslogWriter) Alert(m string) error

Alert logs at LOG_ALERT

func (*MockSyslogWriter) Clear

func (msw *MockSyslogWriter) Clear()

Clear resets the log buffer.

func (*MockSyslogWriter) Close

func (msw *MockSyslogWriter) Close() error

Close releases resources. No other methods may be called after this.

func (*MockSyslogWriter) Crit

func (msw *MockSyslogWriter) Crit(m string) error

Crit logs at LOG_CRIT

func (*MockSyslogWriter) Debug

func (msw *MockSyslogWriter) Debug(m string) error

Debug logs at LOG_DEBUG

func (*MockSyslogWriter) Emerg

func (msw *MockSyslogWriter) Emerg(m string) error

Emerg logs at LOG_EMERG

func (*MockSyslogWriter) Err

func (msw *MockSyslogWriter) Err(m string) error

Err logs at LOG_ERR

func (*MockSyslogWriter) GetAll

func (msw *MockSyslogWriter) GetAll() []*LogMessage

GetAll returns all LogMessages logged (since the last call to Clear(), if applicable).

The caller must not modify the returned slice or its elements.

func (*MockSyslogWriter) GetAllMatching

func (msw *MockSyslogWriter) GetAllMatching(reString string) (matches []*LogMessage)

GetAllMatching returns all LogMessages logged (since the last Clear()) whose text matches the given regexp. The regexp is accepted as a string and compiled on the fly, because convenience is more important than performance.

The caller must not modify the elements of the returned slice.

func (*MockSyslogWriter) Info

func (msw *MockSyslogWriter) Info(m string) error

Info logs at LOG_INFO

func (*MockSyslogWriter) Notice

func (msw *MockSyslogWriter) Notice(m string) error

Notice logs at LOG_NOTICE

func (*MockSyslogWriter) Warning

func (msw *MockSyslogWriter) Warning(m string) error

Warning logs at LOG_WARNING

Jump to

Keyboard shortcuts

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