forked from SierraSoftworks/sentry-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenvironment_test.go
58 lines (47 loc) · 1.44 KB
/
environment_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 (
"os"
"testing"
. "github.com/smartystreets/goconvey/convey"
)
func ExampleEnvironment() {
cl := NewClient(
// You can configure your environment at the client level
Environment("development"),
)
cl.Capture(
// ...or at the event level
Environment("prod"),
)
}
func TestEnvironment(t *testing.T) {
Convey("Environment", t, func() {
Convey("Should register with the default providers", func() {
Convey("If the ENV environment variable is set", func() {
os.Setenv("ENV", "testing")
defer os.Unsetenv("ENV")
opt := testGetOptionsProvider(&environmentOption{})
So(opt, ShouldNotBeNil)
So(opt.(*environmentOption).env, ShouldEqual, "testing")
})
Convey("If the ENVIRONMENT environment variable is set", func() {
os.Setenv("ENVIRONMENT", "testing")
defer os.Unsetenv("ENVIRONMENT")
opt := testGetOptionsProvider(&environmentOption{})
So(opt, ShouldNotBeNil)
So(opt.(*environmentOption).env, ShouldEqual, "testing")
})
})
Convey("Environment()", func() {
Convey("Should return an Option", func() {
So(Environment("testing"), ShouldImplement, (*Option)(nil))
})
})
Convey("Should use the correct class", func() {
So(Environment("test").Class(), ShouldEqual, "environment")
})
Convey("MarshalJSON", func() {
So(testOptionsSerialize(Environment("test")), ShouldResemble, "test")
})
})
}