-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp_test.go
51 lines (41 loc) · 958 Bytes
/
app_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
package feishu
import (
"encoding/json"
"log"
"os"
"testing"
)
var (
appID = os.Getenv("FeiShu-App-ID")
appSecret = os.Getenv("FeiShu-App-Secret")
encryptKey = os.Getenv("FeiShu-App-Encrypt-Key")
verificationToken = os.Getenv("FeiShu-App-Verification-Token")
)
var _ Logger = (*debugLogger)(nil)
type debugLogger struct {
*log.Logger
}
func (l *debugLogger) Debug(s string) {
l.Println(s)
}
func requireNil(t *testing.T, err error) {
t.Helper()
if err != nil {
t.Fatal(err)
}
}
func logIndent(t *testing.T, v interface{}) {
t.Helper()
bs, err := json.MarshalIndent(v, "", " ")
requireNil(t, err)
t.Logf("\n%s", string(bs))
}
func testNewCustomApp() *app {
fsApp := newApp(appID, appSecret,
WithAppDebugLogger(&debugLogger{log.New(os.Stderr, "", log.LstdFlags)}),
WithAppEventEncryptKey(encryptKey),
WithAppEventVerificationToken(verificationToken),
)
fsApp.isCustomApp = true
return fsApp
}