-
Notifications
You must be signed in to change notification settings - Fork 14
/
goisilon_test.go
76 lines (65 loc) · 1.29 KB
/
goisilon_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
package goisilon
import (
"context"
"flag"
"os"
"testing"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
log "github.com/akutz/gournal"
glogrus "github.com/akutz/gournal/logrus"
)
var (
err error
client *Client
defaultCtx context.Context
)
func init() {
defaultCtx = context.Background()
defaultCtx = context.WithValue(
defaultCtx,
log.AppenderKey(),
glogrus.NewWithOptions(
logrus.StandardLogger().Out,
logrus.DebugLevel,
logrus.StandardLogger().Formatter))
}
func TestMain(m *testing.M) {
flag.Parse()
if testing.Verbose() {
defaultCtx = context.WithValue(
defaultCtx,
log.LevelKey(),
log.DebugLevel)
}
client, err = NewClient(defaultCtx)
if err != nil {
log.WithError(err).Panic(defaultCtx, "error creating test client")
}
os.Exit(m.Run())
}
func assertLen(t *testing.T, obj interface{}, expLen int) {
if !assert.Len(t, obj, expLen) {
t.FailNow()
}
}
func assertError(t *testing.T, err error) {
if !assert.Error(t, err) {
t.FailNow()
}
}
func assertNoError(t *testing.T, err error) {
if !assert.NoError(t, err) {
t.FailNow()
}
}
func assertNil(t *testing.T, i interface{}) {
if !assert.Nil(t, i) {
t.FailNow()
}
}
func assertNotNil(t *testing.T, i interface{}) {
if !assert.NotNil(t, i) {
t.FailNow()
}
}