-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig_test.go
52 lines (44 loc) · 1.37 KB
/
config_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
package blizzapi
import (
"testing"
"github.com/google/go-cmp/cmp"
)
func TestDefaultConfig(t *testing.T) {
expected := Config{
BaseUrl: "us.api.blizzard.com",
ClientID: "abcd-1234",
ClientSecret: "foobar-fizzbuzz",
Locale: "en_US",
Region: "us",
UserAgent: "unknown golang application",
}
actual := Config{
ClientID: "abcd-1234",
ClientSecret: "foobar-fizzbuzz",
Region: "us",
}
if err := actual.Init(); err != nil {
t.Fatalf("Config created with only ClientID and ClientSecret failed with error %s", err.Error())
}
if !cmp.Equal(expected, actual) {
t.Fatalf("Expected config structure does not match actual config structure.")
}
}
func TestMissingClientID(t *testing.T) {
c := Config{ClientSecret: "foobar-fizzbuzz", Region: "us"}
if err := c.Init(); err == nil {
t.Fatalf("Config successfully created without requiring ClientID. Expected failure.")
}
}
func TestMissingClientSecret(t *testing.T) {
c := Config{ClientID: "foobar-fizzbuzz", Region: "us"}
if err := c.Init(); err == nil {
t.Fatalf("Config successfully created without requiring ClientSecret. Expected failure.")
}
}
func TestMissingRegion(t *testing.T) {
c := Config{ClientID: "foobar-fizzbuzz", ClientSecret: "foobar-fizzbuzz"}
if err := c.Init(); err == nil {
t.Fatalf("Config successfully created without requiring Region. Expected failure.")
}
}