MCPcopy Index your code
hub / github.com/dgraph-io/dgraph / TestSubgraphToFastJSON

Function TestSubgraphToFastJSON

query/fastjson_test.go:49–69  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

47}
48
49func TestSubgraphToFastJSON(t *testing.T) {
50 t.Run("With a string result", func(t *testing.T) {
51 sg := subgraphWithSingleResultAndSingleValue(task.FromString("ABC"))
52 assertJSON(t, `{"query":[{"val":"ABC"}]}`, sg)
53 })
54
55 t.Run("With an integer result", func(t *testing.T) {
56 sg := subgraphWithSingleResultAndSingleValue(task.FromInt(42))
57 assertJSON(t, `{"query":[{"val":42}]}`, sg)
58 })
59
60 t.Run("With a valid float result", func(t *testing.T) {
61 sg := subgraphWithSingleResultAndSingleValue(task.FromFloat(42.0))
62 assertJSON(t, `{"query":[{"val":42}]}`, sg)
63 })
64
65 t.Run("With invalid floating points", func(t *testing.T) {
66 assertJSON(t, `{"query":[]}`, subgraphWithSingleResultAndSingleValue(task.FromFloat(math.NaN())))
67 assertJSON(t, `{"query":[]}`, subgraphWithSingleResultAndSingleValue(task.FromFloat(math.Inf(1))))
68 })
69}
70
71func TestEncode(t *testing.T) {
72 enc := newEncoder()

Callers

nothing calls this directly

Calls 6

FromStringFunction · 0.92
FromIntFunction · 0.92
FromFloatFunction · 0.92
assertJSONFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected