-
Notifications
You must be signed in to change notification settings - Fork 3
/
snap_test.go
41 lines (37 loc) · 1.08 KB
/
snap_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
package main
import (
"encoding/json"
"os"
"testing"
"github.com/google/go-cmp/cmp"
)
var (
SnapCards = map[string]string{
"Jubilee": "test_data/snap_jubilee.json",
"Asgard": "test_data/snap_asgard.json",
}
)
func TestSnapCard(t *testing.T) {
tables := []struct {
cardname string
output string
}{
{"Jubilee", "*<https://marvelsnap.io/card/jubilee-66|Jubilee>* - :mana-4: · ⚔️ 1 ⚔️ · On Reveal: Play a card from your deck at this location. · (_Collection Level 222-450 (Pool 2)_)"},
{"Asgard", "*<https://marvelsnap.io/card/asgard-284|Asgard>* - After turn 4, whoever is winning here draws 2 cards."},
}
for _, table := range tables {
fi, err := os.Open(SnapCards[table.cardname])
if err != nil {
t.Fatalf("Unable to open %v: %v", table.cardname, err)
}
var r SnapResponse
err = json.NewDecoder(fi).Decode(&r)
if err != nil {
t.Errorf("Something went wrong parsing the response: %s", err)
}
fc := formatSnapCard(r.Card[0])
if diff := cmp.Diff(fc, table.output); diff != "" {
t.Errorf("Incorrect card (-want +got):\n%s", diff)
}
}
}