You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
wechat-bot/text_test.go

27 lines
786 B
Go

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package wxworkbot
import (
"encoding/json"
"github.com/stretchr/testify/assert"
"testing"
)
func TestTextMessage(t *testing.T) {
jsonString := `
{
"msgtype": "text",
"text": {
"content": "广州今日天气29度大部分多云降雨概率60%",
"mentioned_list":["wangqing","@all"],
"mentioned_mobile_list":["13800001111","@all"]
}
}`
var textMsg textMessage
err := json.Unmarshal([]byte(jsonString), &textMsg)
assert.Nil(t, err)
assert.Equal(t, textMsg.MsgType, "text")
assert.Equal(t, textMsg.Text.Content, "广州今日天气29度大部分多云降雨概率60%")
assert.Equal(t, textMsg.Text.MentionedList, []string{"wangqing", "@all"})
assert.Equal(t, textMsg.Text.MentionedMobileList, []string{"13800001111", "@all"})
}