-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi_test.go
49 lines (42 loc) · 1017 Bytes
/
api_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
package wpcom
import (
"flag"
"log"
"code.google.com/p/goconf/conf"
)
var testconf *conf.ConfigFile
var foundSitesForSiteByString = make(map[int]string)
var foundNotesForTesting []Notification
func init() {
var err error
var cfongigFile string
flag.StringVar(&cfongigFile, "cfg", "production.conf", "path to the config file for tests")
flag.Parse()
testconf, err = conf.ReadConfigFile(cfongigFile)
if err != nil {
log.Fatalf("Got error parsing test.conf: %s", err.Error())
}
}
func configTestClient(c *Client) *Client {
if testconf.HasOption("default", "prefix") {
prefix, err := testconf.GetString("default", "prefix")
if err != nil {
log.Fatalf(err.Error())
}
if prefix != "" {
c.Prefix(prefix)
c.InsecureSkipVerify(true)
}
}
return c
}
func getTestClient() *Client {
key, err := testconf.GetString("user", "token")
if err != nil {
log.Fatalf(err.Error())
}
return configTestClient(New(key))
}
func getTestAnonymousClient() *Client {
return configTestClient(New())
}