-
Notifications
You must be signed in to change notification settings - Fork 3
/
mlb_test.go
63 lines (50 loc) · 1.01 KB
/
mlb_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
package mlb_test
import (
"flag"
"fmt"
"os"
"testing"
"github.com/stevepartridge/mlb"
)
var (
mlbApi *mlb.Mlb
)
func TestMain(m *testing.M) {
var err error
mlbApi, err = mlb.New()
if err != nil {
fmt.Println("Error - Should not see error:" + err.Error())
return
}
flag.BoolVar(&mlbApi.Debug, "debug", false, "go test -v -debug [-cover ...]")
flag.Parse()
os.Exit(m.Run())
}
func Test_NewMlbInstance_Success(t *testing.T) {
mlbApi, err := mlb.New()
if err != nil {
t.Error("Should not see error:" + err.Error())
}
if mlbApi == nil {
t.Error("mlbApi should not be nil.")
}
}
func Test_NewMlbInstanceWithDebug_Success(t *testing.T) {
mlbApi, err := mlb.New()
if err != nil {
t.Error("Should not see error:" + err.Error())
}
if mlbApi == nil {
t.Error("mlbApi should not be nil.")
}
oldDebug := mlbApi.Debug
if !mlbApi.Debug {
mlbApi.Debug = true
}
if !mlbApi.Debug {
t.Error("Debug should be true, because, seriously just set it.")
}
if !oldDebug {
mlbApi.Debug = false
}
}