wechat-bot/text_test.go
2022-07-21 23:10:41 +08:00

27 lines
786 B
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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"})
}