-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient_test.go
55 lines (53 loc) · 1.58 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
package feishu
import (
"os"
"testing"
)
func TestClient_SendMessageStr(t *testing.T) {
json := `{
"msg_type": "interactive",
"card": {
"config": {
"wide_screen_mode": true,
"enable_forward": true
},
"elements": [{
"tag": "div",
"text": {
"content": "**西湖**,位于浙江省杭州市西湖区龙井路1号,杭州市区西部,景区总面积49平方千米,汇水面积为21.22平方千米,湖面面积为6.38平方千米。",
"tag": "lark_md"
}
}, {
"actions": [{
"tag": "button",
"text": {
"content": "更多景点介绍 :玫瑰:",
"tag": "lark_md"
},
"url": "https://www.example.com",
"type": "default",
"value": {}
}],
"tag": "action"
}],
"header": {
"title": {
"content": "今日旅游推荐",
"tag": "plain_text"
}
}
}
} `
client := NewClient()
client.Webhook = os.Getenv("webhook")
client.Secret = os.Getenv("secret")
rep, err := client.SendMessageStr(json)
if err != nil {
t.Error("send message error", err)
}
if rep.IsSuccess() {
t.Log("send message success")
} else {
t.Errorf("send message failed: code %d, msg: %s", rep.Code, rep.Msg)
}
}