-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfooter_test.go
50 lines (44 loc) · 1.32 KB
/
footer_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 godiscordwebhook
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
)
// To run this test individually, run the command:
// go test -v -timeout 30s -run ^TestCreateFooter$ go-discord-webhook
func TestCreateFooter(t *testing.T) {
tests := []struct {
Name, IconUrl string
}{
{Name: "Test", IconUrl: "https://github.com/"},
{Name: "", IconUrl: "https://github.com/"},
{Name: "Test", IconUrl: ""},
}
for testNum, test := range tests {
t.Run(fmt.Sprintf("Test #%v", testNum+1), func(t *testing.T) {
result := createFooter(test.Name, test.IconUrl)
if assert.NotNil(t, result, "result should not be nil") {
assert.Equal(t, test.Name, result.Text)
assert.Equal(t, test.IconUrl, result.IconURL)
}
})
}
}
// To run this test individually, run the command:
// go test -v -timeout 30s -run ^TestSetFooter$ go-discord-webhook
func TestSetFooter(t *testing.T) {
tests := []struct {
Footer Footer
}{
{Footer: Footer{Text: "Test", IconURL: "Test"}},
}
for testNum, test := range tests {
t.Run(fmt.Sprintf("Test #%v", testNum+1), func(t *testing.T) {
w := newWebhook()
setFooter(w, test.Footer)
assert.Equal(t, test.Footer, w.Embeds[0].Footer)
assert.Equal(t, test.Footer.Text, w.Embeds[0].Footer.Text)
assert.Equal(t, test.Footer.IconURL, w.Embeds[0].Footer.IconURL)
})
}
}