-
Notifications
You must be signed in to change notification settings - Fork 13
/
notify_test.go
60 lines (52 loc) · 1.41 KB
/
notify_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
59
60
package dingtalk_robot
import (
"os"
"testing"
)
func TestRobot_SendMessage(t *testing.T) {
//t.SkipNow()
msg := map[string]interface{}{
"msgtype": "text",
"text": map[string]string{
"content": "这是一条golang钉钉消息测试.",
},
"at": map[string]interface{}{
"atMobiles": []string{},
"isAtAll": false,
},
}
robot := NewRobot(os.Getenv("ROBOT_TOKEN"), os.Getenv("ROBOT_SECRET"))
if err := robot.SendMessage(msg); err != nil {
t.Error(err)
}
}
func TestRobot_SendTextMessage(t *testing.T) {
robot := NewRobot(os.Getenv("ROBOT_TOKEN"), os.Getenv("ROBOT_SECRET"))
if err := robot.SendTextMessage("普通文本消息", []string{}, false); err != nil {
t.Error(err)
}
}
func TestRobot_SendMarkdownMessage(t *testing.T) {
robot := NewRobot(os.Getenv("ROBOT_TOKEN"), os.Getenv("ROBOT_SECRET"))
err := robot.SendMarkdownMessage(
"Markdown Test Title",
"### Markdown 测试消息\n* 谷歌: [Google](https://www.google.com/)\n* 一张图片\n ![](https://avatars0.githubusercontent.com/u/40748346)",
[]string{},
false,
)
if err != nil {
t.Error(err)
}
}
func TestRobot_SendLinkMessage(t *testing.T) {
robot := NewRobot(os.Getenv("ROBOT_TOKEN"), os.Getenv("ROBOT_SECRET"))
err := robot.SendLinkMessage(
"Link Test Title",
"这是一条链接测试消息",
"https://github.com/JetBlink",
"https://avatars0.githubusercontent.com/u/40748346",
)
if err != nil {
t.Error(err)
}
}