forked from CatchZeng/dingtalk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
link_test.go
50 lines (44 loc) · 982 Bytes
/
link_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
package dingtalk
import (
"reflect"
"testing"
)
func TestLinkMessage_ToByte(t *testing.T) {
msg := NewLinkMessage()
_, _ = msg.ToByte()
if msg.MsgType != MsgTypeLink {
t.Errorf("LinkMessage.ToByte() type error")
}
}
func TestNewLinkMessage(t *testing.T) {
tests := []struct {
name string
want *LinkMessage
}{
{
name: "Should return a LinkMessage instance",
want: &LinkMessage{},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := NewLinkMessage(); !reflect.DeepEqual(got, tt.want) {
t.Errorf("NewLinkMessage() = %v, want %v", got, tt.want)
}
})
}
}
func TestLinkMessage_SetLink(t *testing.T) {
got := NewLinkMessage()
got.SetLink("title", "text", "picURL", "messageURL")
want := NewLinkMessage()
want.Link = Link{
Title: "title",
Text: "text",
PicURL: "picURL",
MessageURL: "messageURL",
}
if !reflect.DeepEqual(got, want) {
t.Errorf("SetLink() = %v, want %v", got, want)
}
}