-
Notifications
You must be signed in to change notification settings - Fork 0
/
bool_test.go
38 lines (31 loc) · 1004 Bytes
/
bool_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
package confunc_test
import (
"github.com/alperkose/confunc"
"strconv"
"testing"
)
func Test_BoolFunc(t *testing.T) {
expectedValue := true
configurationKey := "myConfig"
configUnderTest := confunc.
From(confunc.Map(map[string]string{configurationKey: strconv.FormatBool(expectedValue)})).
Bool(configurationKey)
actualValue := configUnderTest()
if actualValue != expectedValue {
t.Errorf("expected '%v' to be '%v'", actualValue, expectedValue)
}
}
func Test_BoolFuncWithInterceptor(t *testing.T) {
aValue := false
expectedValue := true
configurationKey := "myConfig"
configUnderTest := confunc.
From(confunc.Map(map[string]string{configurationKey: strconv.FormatBool(aValue)})).
Bool(configurationKey, func(s confunc.Confunc) confunc.Confunc {
return func() (string, error) { return strconv.FormatBool(expectedValue), nil }
})
actualValue := configUnderTest()
if actualValue != expectedValue {
t.Errorf("expected '%v' to be '%v'", actualValue, expectedValue)
}
}