Test that loading first chunk succeeds. No need to test that loaded chunk is valid.
(t *testing.T)
| 102 | |
| 103 | // Test that loading first chunk succeeds. No need to test that loaded chunk is valid. |
| 104 | func TestJSONLoadSuccessFirst(t *testing.T) { |
| 105 | var tests = []struct { |
| 106 | json string |
| 107 | expt string |
| 108 | desc string |
| 109 | }{ |
| 110 | {"[{}]", "[{}]", "empty map"}, |
| 111 | {`[{"closingDelimeter":"}"}]`, `[{"closingDelimeter":"}"}]`, "quoted closing brace"}, |
| 112 | {`[{"company":"dgraph"}]`, `[{"company":"dgraph"}]`, "simple, compact map"}, |
| 113 | { |
| 114 | "[\n {\n \"company\" : \"dgraph\"\n }\n]\n", |
| 115 | "[{\"company\":\"dgraph\"}]", |
| 116 | "simple, pretty map", |
| 117 | }, |
| 118 | { |
| 119 | `[{"professor":"Alastor \"Mad-Eye\" Moody"}]`, |
| 120 | `[{"professor":"Alastor \"Mad-Eye\" Moody"}]`, |
| 121 | "escaped balanced quotes", |
| 122 | }, |
| 123 | { |
| 124 | |
| 125 | `[{"something{": "}something"}]`, |
| 126 | `[{"something{":"}something"}]`, |
| 127 | "escape quoted brackets", |
| 128 | }, |
| 129 | { |
| 130 | `[{"height":"6'0\""}]`, |
| 131 | `[{"height":"6'0\""}]`, |
| 132 | "escaped unbalanced quote", |
| 133 | }, |
| 134 | { |
| 135 | `[{"house":{"Hermione":"Gryffindor","Cedric":"Hufflepuff","Luna":"Ravenclaw","Draco":"Slytherin",}}]`, |
| 136 | `[{"house":{"Hermione":"Gryffindor","Cedric":"Hufflepuff","Luna":"Ravenclaw","Draco":"Slytherin",}}]`, |
| 137 | "nested braces", |
| 138 | }, |
| 139 | } |
| 140 | for _, test := range tests { |
| 141 | chunker := NewChunker(JsonFormat, 1000) |
| 142 | reader := bufioReader(test.json) |
| 143 | json, err := chunker.Chunk(reader) |
| 144 | if err == io.EOF { |
| 145 | // pass |
| 146 | } else { |
| 147 | require.NoError(t, err, test.desc) |
| 148 | } |
| 149 | require.Equal(t, test.expt, json.String(), test.desc) |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | // Test that loading all chunks succeeds. No need to test that loaded chunk is valid. |
| 154 | func TestJSONLoadSuccessAll(t *testing.T) { |
nothing calls this directly
no test coverage detected