-
Notifications
You must be signed in to change notification settings - Fork 0
/
model_test.go
79 lines (65 loc) · 1.34 KB
/
model_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
package legionhq
import (
"encoding/json"
"io/ioutil"
"testing"
)
func TestDataModel(t *testing.T) {
jsonStr, err := ioutil.ReadFile("./sample-data.json")
if err != nil {
t.Fatal(err)
}
var data Data
_ = json.Unmarshal([]byte(jsonStr), &data)
}
func TestGetData(t *testing.T) {
_, err := GetData()
if err != nil {
t.Fatal(err)
}
}
func TestData_UpgradeCards(t *testing.T) {
data, err := GetData()
if err != nil {
t.Fatal(err)
}
cards := data.UpgradeCards()
if len(cards) == 0 {
t.Fatal("expected more than 0 upgrade")
}
for _, card := range cards {
if card.CardType != "upgrade" {
t.Fatal("expected card type \"upgrade\" but got", card.CardType)
}
}
}
func TestData_UnitCards(t *testing.T) {
data, err := GetData()
if err != nil {
t.Fatal(err)
}
cards := data.UnitCards()
if len(cards) == 0 {
t.Fatal("expected more than 0 unit cards")
}
for _, card := range cards {
if card.CardType != "unit" {
t.Fatal("expected card type \"unit\" but got", card.CardType)
}
}
}
func TestData_CommandCards(t *testing.T) {
data, err := GetData()
if err != nil {
t.Fatal(err)
}
cards := data.CommandCards()
if len(cards) == 0 {
t.Fatal("expected more than 0 command cards")
}
for _, card := range cards {
if card.CardType != "command" {
t.Fatal("expected card type \"command\" but got", card.CardType)
}
}
}