-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathslog_test.go
54 lines (41 loc) · 1.31 KB
/
slog_test.go
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
42
43
44
45
46
47
48
49
50
51
52
53
54
package slackscot_test
import (
"github.com/alexandre-normand/slackscot"
"github.com/stretchr/testify/assert"
"log"
"strings"
"testing"
)
func TestLogWhenDebugEnabled(t *testing.T) {
var b strings.Builder
l := log.New(&b, "", 0)
slog := slackscot.NewSLogger(l, true)
slog.Debugf("Writing a log statement for my little %s\n", "red bird")
o := b.String()
assert.Equal(t, "Writing a log statement for my little red bird\n", o)
}
func TestLogWhenDebugDisabled(t *testing.T) {
var b strings.Builder
l := log.New(&b, "", 0)
slog := slackscot.NewSLogger(l, false)
slog.Debugf("Writing a log statement for my little %s\n", "red bird")
o := b.String()
// Nothing should have been logged
assert.Equal(t, "", o)
}
func TestPrintfLogsWhenDebugDisabled(t *testing.T) {
var b strings.Builder
l := log.New(&b, "", 0)
slog := slackscot.NewSLogger(l, false)
slog.Printf("Writing a log statement for my little %s\n", "red bird")
o := b.String()
assert.Equal(t, "Writing a log statement for my little red bird\n", o)
}
func TestPrintfLogsWhenDebugEnabled(t *testing.T) {
var b strings.Builder
l := log.New(&b, "", 0)
slog := slackscot.NewSLogger(l, true)
slog.Printf("Writing a log statement for my little %s\n", "red bird")
o := b.String()
assert.Equal(t, "Writing a log statement for my little red bird\n", o)
}