forked from johannesboyne/gofakes3
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlog_test.go
More file actions
41 lines (34 loc) · 732 Bytes
/
log_test.go
File metadata and controls
41 lines (34 loc) · 732 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
35
36
37
38
39
40
41
package gofakes3
import (
"bytes"
"log"
"testing"
)
func TestStdLog(t *testing.T) {
var buf bytes.Buffer
std := log.New(&buf, "", 0)
l := StdLog(std)
l.Print(LogErr, "yep1", 1)
l.Print(LogErr, "yep2", 2)
if buf.String() != "ERR yep1 1\nERR yep2 2\n" {
t.Fatal()
}
}
func TestStdLogLevels(t *testing.T) {
var buf bytes.Buffer
std := log.New(&buf, "", 0)
l := StdLog(std, LogErr)
l.Print(LogErr, "yep1", 1)
l.Print(LogWarn, "yep2", 2)
l.Print(LogInfo, "yep3", 3)
if buf.String() != "ERR yep1 1\n" {
t.Fatal()
}
}
func TestDiscardLog(t *testing.T) {
d := DiscardLog()
// if it doesn't panic, that's all we can test!
d.Print(LogErr, "yep1", 1)
d.Print(LogWarn, "yep2", 2)
d.Print(LogInfo, "yep3", 3)
}