-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient_test.go
58 lines (47 loc) · 1.18 KB
/
client_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
54
55
56
57
58
package wework_test
import (
"bufio"
"os"
"strings"
"github.com/jasonwwl/go-wework"
)
func LoadEnv() error {
file, err := os.Open(".env")
if err != nil {
return err
}
defer file.Close()
scanner := bufio.NewScanner(file)
for scanner.Scan() {
line := scanner.Text()
if len(line) == 0 || line[0] == '#' {
continue
}
parts := strings.SplitN(line, "=", 2)
if len(parts) != 2 {
continue
}
os.Setenv(parts[0], parts[1])
}
return scanner.Err()
}
func newTestClient() *wework.Client {
LoadEnv()
cfg, err := wework.NewConfigBuilder().InternalCorp(wework.InternalCorp{
CorpID: os.Getenv("WEWORK_CORP_ID"),
Secret: os.Getenv("WEWORK_SECRET"),
AgentID: os.Getenv("WEWORK_AGENT_ID"),
}).OpenCorp(wework.OpenCorp{
ProviderCorpID: os.Getenv("WEWORK_PROVIDER_CORP_ID"),
ProviderSecret: os.Getenv("WEWORK_PROVIDER_SECRET"),
SuiteID: os.Getenv("WEWORK_SUITE_ID"),
SuiteSecret: os.Getenv("WEWORK_SUITE_SECRET"),
SuiteToken: os.Getenv("WEWORK_SUITE_TOKEN"),
SuiteEncodingAES: os.Getenv("WEWORK_SUITE_AES_KEY"),
AuthCorpID: os.Getenv("WEWORK_AUTH_CORP_ID"),
}).Build()
if err != nil {
panic(err)
}
return wework.NewClient(cfg)
}