forked from SierraSoftworks/sentry-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtimestamp_test.go
45 lines (38 loc) · 1.03 KB
/
timestamp_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
package sentry
import (
"encoding/json"
"fmt"
"testing"
"time"
. "github.com/smartystreets/goconvey/convey"
)
func ExampleTimestamp() {
cl := NewClient()
cl.Capture(
// You can specify the timestamp when sending an event to Sentry
Timestamp(time.Now()),
)
}
func TestTimestamp(t *testing.T) {
Convey("Timestamp", t, func() {
Convey("Should register itself with the default providers", func() {
opt := testGetOptionsProvider(Timestamp(time.Now()))
So(opt, ShouldNotBeNil)
})
Convey("Timestamp()", func() {
Convey("Should use the correct Class()", func() {
So(Timestamp(time.Now()).Class(), ShouldEqual, "timestamp")
})
Convey("MarshalJSON", func() {
Convey("Should marshal to a string", func() {
Convey("Should marshal to a string", func() {
t := time.Now()
b, err := json.Marshal(Timestamp(t))
So(err, ShouldBeNil)
So(string(b), ShouldEqual, fmt.Sprintf(`"%s"`, t.UTC().Format("2006-01-02T15:04:05")))
})
})
})
})
})
}