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

Function TestJSONLoadSuccessAll

chunker/chunk_test.go:154–217  ·  view source on GitHub ↗

Test that loading all chunks succeeds. No need to test that loaded chunk is valid.

(t *testing.T)

Source from the content-addressed store, hash-verified

152
153// Test that loading all chunks succeeds. No need to test that loaded chunk is valid.
154func TestJSONLoadSuccessAll(t *testing.T) {
155 var testDoc = `
156[
157 {},
158 {
159 "closingDelimeter" : "}"
160 },
161 {
162 "company" : "dgraph",
163 "age": 3
164 },
165 {
166 "professor" : "Alastor \"Mad-Eye\" Moody",
167 "height" : "6'0\""
168 },
169 {
170 "house" : {
171 "Hermione" : "Gryffindor",
172 "Cedric" : "Hufflepuff",
173 "Luna" : "Ravenclaw",
174 "Draco" : "Slytherin"
175 }
176 }
177]`
178 var testChunks = []string{
179 `{}`,
180 `{
181 "closingDelimeter" : "}"
182 }`,
183 `{
184 "company" : "dgraph",
185 "age": 3
186 }`,
187 `{
188 "professor" : "Alastor \"Mad-Eye\" Moody",
189 "height" : "6'0\""
190 }`,
191 `{
192 "house" : {
193 "Hermione" : "Gryffindor",
194 "Cedric" : "Hufflepuff",
195 "Luna" : "Ravenclaw",
196 "Draco" : "Slytherin"
197 }
198 }`,
199 }
200
201 chunker := NewChunker(JsonFormat, 1000)
202 reader := bufioReader(testDoc)
203
204 var json *bytes.Buffer
205 var idx int
206
207 var err error
208 for idx = 0; err == nil; idx++ {
209 desc := fmt.Sprintf("reading chunk #%d", idx+1)
210 json, err = chunker.Chunk(reader)
211 if err != io.EOF {

Callers

nothing calls this directly

Calls 4

ChunkMethod · 0.95
NewChunkerFunction · 0.85
bufioReaderFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected