-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathassert_test.go
More file actions
34 lines (26 loc) · 754 Bytes
/
assert_test.go
File metadata and controls
34 lines (26 loc) · 754 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package log
import "testing"
func TestClearAssert(t *testing.T) {
l := Must(NewAssertLog(
WithLevel(Info),
WithPrintLevel(Info),
))
defer l.Close()
l.Debug("debug message")
l.Debugf("formatted %s message", "debug")
l.Info("informational message")
l.Infof("formatted %s message", "informational")
if !Assert(l).Contains(Debug, "debug message") {
t.Errorf("expected debug message not found")
}
if !Assert(l).ContainsFormat(Debug, "formatted %s message") {
t.Errorf("expected 'formatted %%s message' not found at %s level", Debug)
}
if !Assert(l).ContainsLevel(Info) {
t.Errorf("expected info message not found")
}
ClearAssert(l)
if Assert(l).ContainsLevel(Info) {
t.Errorf("expected info message found after clear")
}
}