wechat-bot/text_test.go

27 lines
786 B
Go
Raw Normal View History

2022-07-21 23:10:41 +08:00
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"})
}