MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / AssertLogNotContains

Function AssertLogNotContains

base/logging.go:430–443  ·  view source on GitHub ↗

AssertLogNotContains asserts that the logs produced by function f do not contain string s.

(t *testing.T, s string, f func())

Source from the content-addressed store, hash-verified

428
429// AssertLogNotContains asserts that the logs produced by function f do not contain string s.
430func AssertLogNotContains(t *testing.T, s string, f func()) {
431 // Temporarily override logger output
432 b := &bytes.Buffer{}
433 mw := io.MultiWriter(b, os.Stderr)
434 consoleLogger.Load().logger.SetOutput(mw)
435 // Call the given function
436 f()
437
438 FlushLogBuffers()
439 consoleLogger.Load().FlushBufferToLog()
440 // do not reset output in defer, since we are accessing b.String() after
441 consoleLogger.Load().logger.SetOutput(os.Stderr)
442 assert.NotContains(t, b.String(), s)
443}
444
445// AuditLogContents returns that the audit logs produced by function f.
446func AuditLogContents(t testing.TB, f func(t testing.TB)) []byte {

Callers 2

Calls 4

FlushLogBuffersFunction · 0.85
LoadMethod · 0.80
FlushBufferToLogMethod · 0.80
StringMethod · 0.65

Tested by 2