forked from FuzzyStatic/blizzard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init_test.go
50 lines (43 loc) · 885 Bytes
/
init_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
package blizzard
import (
"context"
"fmt"
"log"
"net/http"
"os"
)
var (
usClient *Client
printOutput string
)
func init() {
var err error
clientID := os.Getenv("CLIENT_ID")
if clientID == "" {
log.Fatal("Set the environment variable CLIENT_ID before retrying.")
}
clientSecret := os.Getenv("CLIENT_SECRET")
if clientSecret == "" {
log.Fatal("Set the environment variable CLIENT_SECRET before retrying.")
}
printOutput = os.Getenv("PRINT_OUTPUT")
if printOutput == "" {
log.Println("Output will not be printed for tests.")
}
usClient, err = NewClient(Config{
ClientID: clientID,
ClientSecret: clientSecret,
HTTPClient: http.DefaultClient,
Region: US,
Locale: EnUS,
})
if err != nil {
fmt.Println(err)
return
}
err = usClient.AccessTokenRequest(context.Background())
if err != nil {
fmt.Println(err)
return
}
}