1{
2 "description": "poc-gridfs",
3 "schemaVersion": "1.0",
4 "createEntities": [
5 {
6 "client": {
7 "id": "client0"
8 }
9 },
10 {
11 "database": {
12 "id": "database0",
13 "client": "client0",
14 "databaseName": "gridfs-tests"
15 }
16 },
17 {
18 "bucket": {
19 "id": "bucket0",
20 "database": "database0"
21 }
22 },
23 {
24 "collection": {
25 "id": "bucket0_files_collection",
26 "database": "database0",
27 "collectionName": "fs.files"
28 }
29 },
30 {
31 "collection": {
32 "id": "bucket0_chunks_collection",
33 "database": "database0",
34 "collectionName": "fs.chunks"
35 }
36 }
37 ],
38 "initialData": [
39 {
40 "collectionName": "fs.files",
41 "databaseName": "gridfs-tests",
42 "documents": [
43 {
44 "_id": {
45 "$oid": "000000000000000000000005"
46 },
47 "length": 10,
48 "chunkSize": 4,
49 "uploadDate": {
50 "$date": "1970-01-01T00:00:00.000Z"
51 },
52 "md5": "57d83cd477bfb1ccd975ab33d827a92b",
53 "filename": "length-10",
54 "contentType": "application/octet-stream",
55 "aliases": [],
56 "metadata": {}
57 }
58 ]
59 },
60 {
61 "collectionName": "fs.chunks",
62 "databaseName": "gridfs-tests",
63 "documents": [
64 {
65 "_id": {
66 "$oid": "000000000000000000000005"
67 },
68 "files_id": {
69 "$oid": "000000000000000000000005"
70 },
71 "n": 0,
72 "data": {
73 "$binary": {
74 "base64": "ESIzRA==",
75 "subType": "00"
76 }
77 }
78 },
79 {
80 "_id": {
81 "$oid": "000000000000000000000006"
82 },
83 "files_id": {
84 "$oid": "000000000000000000000005"
85 },
86 "n": 1,
87 "data": {
88 "$binary": {
89 "base64": "VWZ3iA==",
90 "subType": "00"
91 }
92 }
93 },
94 {
95 "_id": {
96 "$oid": "000000000000000000000007"
97 },
98 "files_id": {
99 "$oid": "000000000000000000000005"
100 },
101 "n": 2,
102 "data": {
103 "$binary": {
104 "base64": "mao=",
105 "subType": "00"
106 }
107 }
108 }
109 ]
110 }
111 ],
112 "tests": [
113 {
114 "description": "Delete when length is 10",
115 "operations": [
116 {
117 "name": "delete",
118 "object": "bucket0",
119 "arguments": {
120 "id": {
121 "$oid": "000000000000000000000005"
122 }
123 }
124 }
125 ],
126 "outcome": [
127 {
128 "collectionName": "fs.files",
129 "databaseName": "gridfs-tests",
130 "documents": []
131 },
132 {
133 "collectionName": "fs.chunks",
134 "databaseName": "gridfs-tests",
135 "documents": []
136 }
137 ]
138 },
139 {
140 "description": "Download when there are three chunks",
141 "operations": [
142 {
143 "name": "download",
144 "object": "bucket0",
145 "arguments": {
146 "id": {
147 "$oid": "000000000000000000000005"
148 }
149 },
150 "expectResult": {
151 "$$matchesHexBytes": "112233445566778899aa"
152 }
153 }
154 ]
155 },
156 {
157 "description": "Download when files entry does not exist",
158 "operations": [
159 {
160 "name": "download",
161 "object": "bucket0",
162 "arguments": {
163 "id": {
164 "$oid": "000000000000000000000000"
165 }
166 },
167 "expectError": {
168 "isError": true
169 }
170 }
171 ]
172 },
173 {
174 "description": "Download when an intermediate chunk is missing",
175 "operations": [
176 {
177 "name": "deleteOne",
178 "object": "bucket0_chunks_collection",
179 "arguments": {
180 "filter": {
181 "files_id": {
182 "$oid": "000000000000000000000005"
183 },
184 "n": 1
185 }
186 },
187 "expectResult": {
188 "deletedCount": 1
189 }
190 },
191 {
192 "name": "download",
193 "object": "bucket0",
194 "arguments": {
195 "id": {
196 "$oid": "000000000000000000000005"
197 }
198 },
199 "expectError": {
200 "isError": true
201 }
202 }
203 ]
204 },
205 {
206 "description": "Upload when length is 5",
207 "operations": [
208 {
209 "name": "upload",
210 "object": "bucket0",
211 "arguments": {
212 "filename": "filename",
213 "source": {
214 "$$hexBytes": "1122334455"
215 },
216 "chunkSizeBytes": 4
217 },
218 "expectResult": {
219 "$$type": "objectId"
220 },
221 "saveResultAsEntity": "oid0"
222 },
223 {
224 "name": "find",
225 "object": "bucket0_files_collection",
226 "arguments": {
227 "filter": {},
228 "sort": {
229 "uploadDate": -1
230 },
231 "limit": 1
232 },
233 "expectResult": [
234 {
235 "_id": {
236 "$$matchesEntity": "oid0"
237 },
238 "length": 5,
239 "chunkSize": 4,
240 "uploadDate": {
241 "$$type": "date"
242 },
243 "md5": {
244 "$$unsetOrMatches": "283d4fea5dded59cf837d3047328f5af"
245 },
246 "filename": "filename"
247 }
248 ]
249 },
250 {
251 "name": "find",
252 "object": "bucket0_chunks_collection",
253 "arguments": {
254 "filter": {
255 "_id": {
256 "$gt": {
257 "$oid": "000000000000000000000007"
258 }
259 }
260 },
261 "sort": {
262 "n": 1
263 }
264 },
265 "expectResult": [
266 {
267 "_id": {
268 "$$type": "objectId"
269 },
270 "files_id": {
271 "$$matchesEntity": "oid0"
272 },
273 "n": 0,
274 "data": {
275 "$binary": {
276 "base64": "ESIzRA==",
277 "subType": "00"
278 }
279 }
280 },
281 {
282 "_id": {
283 "$$type": "objectId"
284 },
285 "files_id": {
286 "$$matchesEntity": "oid0"
287 },
288 "n": 1,
289 "data": {
290 "$binary": {
291 "base64": "VQ==",
292 "subType": "00"
293 }
294 }
295 }
296 ]
297 }
298 ]
299 }
300 ]
301}
View as plain text