forked from mattermost/action-mattermost-notify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmattermost_test.go
60 lines (56 loc) · 1.24 KB
/
mattermost_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
51
52
53
54
55
56
57
58
59
60
package main_test
import (
"testing"
"github.com/mattermost/mattermost-server/v5/model"
"github.com/stretchr/testify/assert"
notify "github.com/mattermost/action-mattermost-notify"
)
func TestIsEmpty(t *testing.T) {
for name, test := range map[string]struct {
request *model.IncomingWebhookRequest
result bool
}{
"nil": {
request: nil,
result: true,
},
"Text and Attachments empty": {
request: &model.IncomingWebhookRequest{},
result: true,
},
"Text not empty": {
request: &model.IncomingWebhookRequest{
Text: "some Text",
},
result: false,
},
"Attachments not empty": {
request: &model.IncomingWebhookRequest{
Attachments: []*model.SlackAttachment{{
Text: "some Text",
}},
},
result: false,
},
"Attachments not empty, but no text": {
request: &model.IncomingWebhookRequest{
Attachments: []*model.SlackAttachment{},
},
result: false,
},
"Text and Attachments not empty": {
request: &model.IncomingWebhookRequest{
Text: "some Text",
Attachments: []*model.SlackAttachment{{
Text: "some Text",
}},
},
result: false,
},
} {
t.Run(name, func(t *testing.T) {
r := notify.IsEmpty(test.request)
assert.Equal(t, test.result, r)
})
}
}