-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathmedia_test.go
46 lines (43 loc) · 1.07 KB
/
media_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
package wxworkbot
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestUploadMediaAndSendTemplateCardMessage(t *testing.T) {
botKey := GetTestBotKey()
if len(botKey) == 0 {
return
}
bot := New(botKey)
fileBytes := []byte("Here is a string....")
media, err := bot.UploadMedia(
"test.txt",
&fileBytes,
)
assert.Nil(t, err)
assert.NotNil(t, media)
err = bot.Send(TemplateCard{
CardType: TemplateCardTypeText,
Source: &TemplateCardSource{
IconUrl: strRef("https://wework.qpic.cn/wwpic/252813_jOfDHtcISzuodLa_1629280209/0"),
Desc: strRef("企业微信"),
DescColor: TemplateCardSourceDescColorRed,
},
MainTitle: TemplateCardMainTitle{
Title: strRef("下载 test.txt"),
},
HorizontalContentList: &[]TemplateCardHorizontalContent{
{
KeyName: "test.txt",
Value: strRef("点击下载"),
Type: TemplateCardHorizontalContentTypeAttachment,
MediaID: &media.MediaID,
},
},
CardAction: TemplateCardAction{
Type: TemplateCardActionTypeUrl,
Url: strRef("https://baidu.com"),
},
})
assert.Nil(t, err)
}