-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_test.go
46 lines (43 loc) · 967 Bytes
/
main_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
package sentry_to_slack
import (
"fmt"
"os"
"testing"
"github.com/stretchr/testify/assert"
)
func TestCreateRequest(t *testing.T) {
os.Setenv("SLACK_CHANNEL", "test_channel")
os.Setenv("TAGS", "server_name ,environment")
b := Body{
Url: "https://test.example.com",
Level: "error",
Project: "test_project",
Event: Event{
Title: "TestError",
Culprit: "This is test error",
Tags: [][]string{
{"environment", "test"},
{"server_name", "test.example.com"},
{"ignore", "test"},
},
},
}
r := CreateRequest(b)
assert.Equal(t, r, Request{
Channel: "test_channel",
Attachments: []RequestAttachment{
{
Title: fmt.Sprintf("<%s|%s>",
b.Url,
b.Event.Title,
),
Color: b.Color(),
Fields: []RequestField{
{Title: "", Value: b.Event.Culprit},
{Title: "server_name", Value: "test.example.com", Short: true},
{Title: "environment", Value: "test", Short: true},
},
},
},
})
}