-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathlog_test.go
More file actions
37 lines (30 loc) · 903 Bytes
/
log_test.go
File metadata and controls
37 lines (30 loc) · 903 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
package log
import (
"strings"
"testing"
"github.com/stretchr/testify/assert"
)
func TestContains(t *testing.T) {
// Flush buffers from previous tests.
GetStdOut()
GetStdErr()
old := DebugVisible()
SetDebugVisible(1)
assert.False(t, containsStdOut("info"))
assert.False(t, containsStdErr("error"))
Info("Some information")
assert.True(t, containsStdOut("info"))
Error("Some error")
assert.True(t, containsStdErr("error"))
SetDebugVisible(old)
}
// containsStdErr will look for str in StdErr and flush the output-buffer.
// If you need to look at multiple strings, use GetStdErr.
func containsStdErr(str string) bool {
return strings.Contains(GetStdErr(), str)
}
// containsStdOut will look for str in StdOut and flush the output-buffer.
// If you need to look at multiple strings, use GetStdOut.
func containsStdOut(str string) bool {
return strings.Contains(GetStdOut(), str)
}