-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathint8_test.go
More file actions
46 lines (37 loc) · 1016 Bytes
/
int8_test.go
File metadata and controls
46 lines (37 loc) · 1016 Bytes
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 envy_test
import (
"testing"
"github.com/pyr33x/envy"
"github.com/stretchr/testify/assert"
)
func TestGetInt8(t *testing.T) {
var fallback int8 = 10
t.Run("GetNonExistingInt8WithFallback", func(t *testing.T) {
assert.Equal(t, fallback, envy.GetInt8("KEY", fallback))
})
t.Run("GetInvalidInt8WithFallback", func(t *testing.T) {
t.Setenv("KEY", "INVALID")
assert.Equal(t, fallback, envy.GetInt8("KEY", fallback))
})
t.Run("GetValidInt8WithFallback", func(t *testing.T) {
t.Setenv("KEY", "12")
assert.Equal(t, int8(12), envy.GetInt8("KEY", fallback))
})
}
func TestMustInt8(t *testing.T) {
t.Run("MustGetNonExistingInt8", func(t *testing.T) {
assert.Panics(t, func() {
envy.MustGetInt8("KEY")
})
})
t.Run("MustGetInvalidInt8", func(t *testing.T) {
t.Setenv("KEY", "INVALID")
assert.Panics(t, func() {
envy.MustGetInt8("KEY")
})
})
t.Run("MustGetValidInt8", func(t *testing.T) {
t.Setenv("KEY", "12")
assert.Equal(t, int8(12), envy.MustGetInt8("KEY"))
})
}