MCPcopy
hub / github.com/dgraph-io/dgraph / TestConvertJSON

Function TestConvertJSON

dgraph/cmd/root_test.go:18–56  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

16)
17
18func TestConvertJSON(t *testing.T) {
19 config := `{
20 "mutations": "strict",
21 "badger": {
22 "compression": "zstd:1",
23 "numgoroutines": 5
24 },
25 "limit": {
26 "query_edge": 1000000
27 },
28 "raft": {
29 "idx": 2,
30 "learner": true
31 },
32 "security": {
33 "whitelist": "127.0.0.1,0.0.0.0"
34 }
35 }`
36
37 var converted map[string]string
38 err := json.NewDecoder(convertJSON(config)).Decode(&converted)
39 require.NoError(t, err)
40
41 require.Equal(t, "strict", converted["mutations"])
42
43 badger := z.NewSuperFlag(converted["badger"])
44 require.Equal(t, "zstd:1", badger.GetString("compression"))
45 require.Equal(t, int64(5), badger.GetInt64("numgoroutines"))
46
47 limit := z.NewSuperFlag(converted["limit"])
48 require.Equal(t, int64(1000000), limit.GetInt64("query-edge"))
49
50 raft := z.NewSuperFlag(converted["raft"])
51 require.Equal(t, int64(2), raft.GetInt64("idx"))
52 require.Equal(t, true, raft.GetBool("learner"))
53
54 security := z.NewSuperFlag(converted["security"])
55 require.Equal(t, "127.0.0.1,0.0.0.0", security.GetString("whitelist"))
56}
57
58func TestConvertYAML(t *testing.T) {
59 hier := `

Callers

nothing calls this directly

Calls 1

convertJSONFunction · 0.85

Tested by

no test coverage detected