-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlevels_test.go
64 lines (49 loc) · 1014 Bytes
/
levels_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
55
56
57
58
59
60
61
62
63
64
package glog
import (
"fmt"
"testing"
"github.com/onsi/gomega"
)
func TestNewLogLevel(t *testing.T) {
g := gomega.NewGomegaWithT(t)
cases := []struct {
input string
expected LogLevel
ok bool
}{
{"debug", Debug, true},
{"info", Info, true},
{"notice", Notice, true},
{"warning", Warning, true},
{"error", Error, true},
{"critical", Critical, true},
{"foobar", Debug, false},
}
for _, c := range cases {
got, err := NewLogLevel(c.input)
if c.ok {
g.Expect(err).To(gomega.BeNil())
} else {
g.Expect(err).NotTo(gomega.BeNil())
}
g.Expect(got).To(gomega.Equal(c.expected))
}
}
func TestLogLevelString(t *testing.T) {
g := gomega.NewGomegaWithT(t)
cases := []struct {
input LogLevel
expected string
}{
{Debug, "debug"},
{Info, "info"},
{Notice, "notice"},
{Warning, "warning"},
{Error, "error"},
{Critical, "critical"},
}
for _, c := range cases {
got := fmt.Sprint(c.input)
g.Expect(got).To(gomega.Equal(c.expected))
}
}