-
Notifications
You must be signed in to change notification settings - Fork 0
/
json_test.go
37 lines (33 loc) · 887 Bytes
/
json_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
package mongoes
import (
"testing"
)
func TestReadJSONFromFile(t *testing.T) {
var m map[string]interface{}
err := ReadJSONFromFile("./test-files/test.json", &m)
if err != nil {
t.Error("ReadJSON From File should not return error")
}
}
func TestGetStringJSON(t *testing.T) {
var m map[string]interface{}
err := ReadJSONFromFile("./test-files/test.json", &m)
if err != nil {
t.Error("ReadJSON From File should not return error")
}
val := GetStringJSON(m, "mongodb.uri")
if val != "localhost:27017" {
t.Error("GestSTringJSON return unexpected value")
}
}
func TestGetBoolJSON(t *testing.T) {
var m map[string]interface{}
err := ReadJSONFromFile("./test-files/test.json", &m)
if err != nil {
t.Error("ReadJSON From File should not return error")
}
val := GetBoolJSON(m, "query.is_active")
if val != true {
t.Error("GetBoolJSON return unexpected value")
}
}