This repository has been archived by the owner on Jan 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
integration_test.go
170 lines (134 loc) · 3 KB
/
integration_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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
package logsip_test
import (
"os"
"os/exec"
"testing"
log "github.com/rdeusser/logsip"
)
const testString = "aaa"
func TestNew(t *testing.T) {
logger := log.New()
logger.Info(testString)
}
func TestDebug(t *testing.T) {
log.SetLevel(log.DebugLevel)
log.Debug(testString)
}
func TestDebugf(t *testing.T) {
log.SetLevel(log.DebugLevel)
log.Debugf("%s", testString)
}
func TestDebugln(t *testing.T) {
log.SetLevel(log.DebugLevel)
log.Debugln(testString)
}
func TestInfo(t *testing.T) {
log.Info(testString)
}
func TestInfof(t *testing.T) {
log.Infof("%s", testString)
}
func TestInfoln(t *testing.T) {
log.Infoln(testString)
}
func TestWarn(t *testing.T) {
log.Warn(testString)
}
func TestWarnf(t *testing.T) {
log.Warnf("%s", testString)
}
func TestWarnln(t *testing.T) {
log.Warnln(testString)
}
func TestError(t *testing.T) {
log.Error(testString)
}
func TestErrorf(t *testing.T) {
log.Errorf("%s", testString)
}
func TestErrorln(t *testing.T) {
log.Errorln(testString)
}
func TestFatal(t *testing.T) {
if os.Getenv("BE_CRASHER") == "1" {
log.Fatal(testString)
return
}
cmd := exec.Command(os.Args[0], "-test.run=TestFatal")
cmd.Env = append(os.Environ(), "BE_CRASHER=1")
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
err := cmd.Run()
if e, ok := err.(*exec.ExitError); ok && !e.Success() {
return
}
t.Fatalf("process ran with err %v, want exit status 1", err)
}
func TestFatalf(t *testing.T) {
if os.Getenv("BE_CRASHER") == "1" {
log.Fatalf(testString)
return
}
cmd := exec.Command(os.Args[0], "-test.run=TestFatalf")
cmd.Env = append(os.Environ(), "BE_CRASHER=1")
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
err := cmd.Run()
if e, ok := err.(*exec.ExitError); ok && !e.Success() {
return
}
t.Fatalf("process ran with err %v, want exit status 1", err)
}
func TestFatalln(t *testing.T) {
if os.Getenv("BE_CRASHER") == "1" {
log.Fatalln(testString)
return
}
cmd := exec.Command(os.Args[0], "-test.run=TestFatalln")
cmd.Env = append(os.Environ(), "BE_CRASHER=1")
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
err := cmd.Run()
if e, ok := err.(*exec.ExitError); ok && !e.Success() {
return
}
t.Fatalf("process ran with err %v, want exit status 1", err)
}
func TestPanic(t *testing.T) {
defer func() {
if r := recover(); r == nil {
t.Errorf("it didn't panic")
}
}()
log.Panic(testString)
}
func TestPanicf(t *testing.T) {
defer func() {
if r := recover(); r == nil {
t.Errorf("it didn't panic")
}
}()
log.Panicf("%s", testString)
}
func TestPanicln(t *testing.T) {
defer func() {
if r := recover(); r == nil {
t.Errorf("it didn't panic")
}
}()
log.Panicln(testString)
}
func TestLevel(t *testing.T) {
log.SetLevel(log.DebugLevel)
log.Debug(testString)
l := log.GetLevel()
if l != log.DebugLevel {
t.Errorf("expected %s, got %s", log.DebugLevel, log.InfoLevel)
}
log.SetLevel(log.InfoLevel)
log.Debug(testString)
n := log.GetLevel()
if n != log.InfoLevel {
t.Errorf("expected %s, got %s", log.InfoLevel, log.DebugLevel)
}
}