Documentation ¶
Index ¶
- type LogMessage
- type MockCADatabase
- type MockDNS
- func (mock *MockDNS) ExchangeOne(hostname string, qt uint16) (rsp *dns.Msg, rtt time.Duration, err error)
- func (mock *MockDNS) LookupCAA(domain string) ([]*dns.CAA, time.Duration, error)
- func (mock *MockDNS) LookupCNAME(domain string) (string, time.Duration, error)
- func (mock *MockDNS) LookupDNAME(domain string) (string, time.Duration, error)
- func (mock *MockDNS) LookupHost(hostname string) ([]net.IP, time.Duration, time.Duration, error)
- func (mock *MockDNS) LookupMX(domain string) ([]string, time.Duration, error)
- func (mock *MockDNS) LookupTXT(hostname string) ([]string, time.Duration, error)
- type MockSyslogWriter
- func (msw *MockSyslogWriter) Alert(m string) error
- func (msw *MockSyslogWriter) Clear()
- func (msw *MockSyslogWriter) Close() error
- func (msw *MockSyslogWriter) Crit(m string) error
- func (msw *MockSyslogWriter) Debug(m string) error
- func (msw *MockSyslogWriter) Emerg(m string) error
- func (msw *MockSyslogWriter) Err(m string) error
- func (msw *MockSyslogWriter) GetAll() []*LogMessage
- func (msw *MockSyslogWriter) GetAllMatching(reString string) (matches []*LogMessage)
- func (msw *MockSyslogWriter) Info(m string) error
- func (msw *MockSyslogWriter) Notice(m string) error
- func (msw *MockSyslogWriter) Warning(m string) error
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) LookupCNAME ¶
LookupCNAME is a mock
func (*MockDNS) LookupDNAME ¶
LookupDNAME is a mock
func (*MockDNS) LookupHost ¶
LookupHost 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) 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) 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