forked from SierraSoftworks/sentry-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmessage_test.go
58 lines (45 loc) · 1.27 KB
/
message_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
package sentry
import (
"testing"
. "github.com/smartystreets/goconvey/convey"
)
func ExampleMessage() {
cl := NewClient()
cl.Capture(
// You can either use just a simple message
Message("this is a simple message"),
)
cl.Capture(
// Or you can provide formatting entries as you would with
// fmt.Sprintf() calls.
Message("this is a %s message (%d/7 would use again)", "formatted", 5),
)
}
func TestMessage(t *testing.T) {
Convey("Message", t, func() {
Convey("Message()", func() {
Convey("Should return an Option", func() {
So(Message("test"), ShouldImplement, (*Option)(nil))
})
Convey("With just a message string", func() {
m := Message("test")
So(m, ShouldNotBeNil)
mi, ok := m.(*messageOption)
So(ok, ShouldBeTrue)
So(mi.Message, ShouldEqual, "test")
})
Convey("With a formatted message", func() {
m := Message("this is a %s", "test")
So(m, ShouldNotBeNil)
mi, ok := m.(*messageOption)
So(ok, ShouldBeTrue)
So(mi.Message, ShouldEqual, "this is a %s")
So(mi.Params, ShouldResemble, []interface{}{"test"})
So(mi.Formatted, ShouldEqual, "this is a test")
})
})
Convey("Should use the correct Class()", func() {
So(Message("test").Class(), ShouldEqual, "sentry.interfaces.Message")
})
})
}