-
Notifications
You must be signed in to change notification settings - Fork 3
/
bnet_test.go
53 lines (50 loc) · 1.42 KB
/
bnet_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
package main
import (
"testing"
"github.com/FuzzyStatic/blizzard/v2/wowgd"
)
func TestDistinguishRealmFromPlayer(t *testing.T) {
wowRealms = &wowgd.RealmIndex{
Realms: []struct {
Key struct {
Href string `json:"href"`
} `json:"key"`
Name string `json:"name"`
ID int `json:"id"`
Slug string `json:"slug"`
}{
{Name: "TestRealm", Slug: "testrealm"},
},
}
type args struct {
input1 string
input2 string
}
tests := []struct {
name string
args args
wantPlayer string
wantRealm string
wantErr bool
}{
{"realm, player", args{"testrealm", "testplayer"}, "testplayer", "testrealm", false},
{"player, realm", args{"testplayer", "testrealm"}, "testplayer", "testrealm", false},
{"notrealm, player", args{"fakerealm", "testplayer"}, "", "", true},
{"player, notrealm", args{"testplayer", "fakerealm"}, "", "", true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
gotRealm, gotPlayer, err := distinguishRealmFromPlayer(tt.args.input1, tt.args.input2)
if (err != nil) != tt.wantErr {
t.Errorf("distinguishRealmFromPlayer() error = %v, wantErr %v", err, tt.wantErr)
return
}
if gotPlayer != tt.wantPlayer {
t.Errorf("distinguishRealmFromPlayer() player got = %v, want %v", gotPlayer, tt.wantPlayer)
}
if gotRealm != tt.wantRealm {
t.Errorf("distinguishRealmFromPlayer() realm got = %v, want %v", gotRealm, tt.wantRealm)
}
})
}
}