This repository was archived by the owner on Jun 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmoment_test.go
74 lines (66 loc) · 1.58 KB
/
moment_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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package wecom
import (
"testing"
"time"
)
// 有时候会触发 41063 错误码,因为异步发送还未到接收人
var testMomentTask = MomentTask{
Text: Text{
Content: "测试发圈",
},
}
var testJobId = ""
var testMomentId = ""
func TestWorkChat_AddMomentTask(t *testing.T) {
resp := testWorkChat.MediaUploadAttachment(testAttachment)
if resp.ErrCode != 0 {
t.Error(resp.ErrorMsg)
return
}
t.Log(resp)
testMomentTask.Attachments = append(testMomentTask.Attachments, Attachments{
Msgtype: "image",
Image: &Image{MediaID: resp.MediaId},
})
testMomentTask.VisibleRange = VisibleRange{SenderList: SenderList{UserList: []string{"jifengwei"}}}
resp1 := testWorkChat.AddMomentTask(testMomentTask)
if resp1.ErrCode != 0 {
t.Error(resp1.ErrorMsg)
return
}
t.Log(resp1)
testJobId = resp1.JobId
}
func TestWorkChat_GetMomentTaskResult(t *testing.T) {
resp := testWorkChat.GetMomentTaskResult(testJobId)
if resp.ErrCode != 0 {
t.Error(resp.ErrorMsg)
return
}
t.Log(resp)
}
func TestWorkChat_GetMomentList(t *testing.T) {
var testFilter = MomentListFilter{
StartTime: time.Now().Unix() - 1000,
EndTime: time.Now().Unix()}
resp := testWorkChat.GetMomentList(testFilter)
if resp.ErrCode != 0 {
t.Error(resp.ErrorMsg)
return
}
for _, moment := range resp.MomentList {
testMomentId = moment.MomentID
}
t.Log(resp)
}
func TestWorkChat_GetMomentTask(t *testing.T) {
var testFilter = MomentTaskFilter{
MomentId: testMomentId,
}
resp := testWorkChat.GetMomentTask(testFilter)
if resp.ErrCode != 0 {
t.Error(resp.ErrorMsg)
return
}
t.Log(resp)
}