getui_test.go
1.9 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package getui
import (
"openapi/pkg/infrastructure/push"
"openapi/pkg/infrastructure/utils"
"testing"
)
func TestGetui(t *testing.T) {
var param = make(map[string]interface{})
param["A"] = "A1"
param["B"] = 2
param["transData"] = struct{ Id int }{Id: 10}
notification := &GetuiNotification{}
err := notification.Init(
push.DebugModule(true),
push.AppId("TkpBI4awmg9fBUx3NWKXS6"),
push.AppKey("5AjJeDOSOZ5ojQpXJFjhg9"),
push.AppMasterSecret("9VnM8MaA6n84Y5VnOIaSvA"),
//单推
push.PushType(push.PushToSingle),
push.ClientId("b5fff5f6b0af551da5f381fa47991828"),
//群推
//push.PushType(push.PushToList),
//push.ClientIds([]string{"b5fff5f6b0af551da5f381fa47991828"}),
push.MsgType(push.SystemTransmission), //push.SystemNotification
push.Title("测试 hello"),
push.Content("hello content"),
push.TransmissionContent(utils.JsonAssertString(param["transData"])),
push.Extra(param),
)
if err != nil {
t.Fatal(err)
}
err = notification.Send(param)
if err != nil {
t.Fatal(err)
}
}
func TestGetuiPrd(t *testing.T) {
var param = make(map[string]interface{})
param["A"] = "A1"
param["B"] = 2
param["transData"] = struct {
Id int `json:"id"`
}{Id: 1}
notification := &GetuiNotification{}
err := notification.Init(
push.DebugModule(true),
push.AppId("WgrbaaStTk7JElrXOCgUg6"),
push.AppKey("FG5lbqVrHa5rS9NVfxNP7"),
push.AppMasterSecret("FW3jMNLJrRARYKv2iqA5H5"),
//单推
//push.PushType(push.PushToSingle),
//push.ClientId("502f4fd7ba5df15ac6b3d5c561efd9ca"),
//群推
push.PushType(push.PushToList),
push.ClientIds([]string{"502f4fd7ba5df15ac6b3d5c561efd9ca"}),
push.MsgType(push.SystemTransmission),
push.Title("hello"),
push.Content("hello content"),
push.TransmissionContent(utils.JsonAssertString(param["transData"])),
push.Extra(param),
)
if err != nil {
t.Fatal(err)
}
err = notification.Send(param)
if err != nil {
t.Fatal(err)
}
}