AssertLogNotContains asserts that the logs produced by function f do not contain string s.
(t *testing.T, s string, f func())
| 428 | |
| 429 | // AssertLogNotContains asserts that the logs produced by function f do not contain string s. |
| 430 | func 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. |
| 446 | func AuditLogContents(t testing.TB, f func(t testing.TB)) []byte { |