|
1 |
| -data: |
2 |
| - files: |
3 |
| - - |
4 |
| - _id: { "$oid" : "000000000000000000000001" } |
5 |
| - length: 0 |
6 |
| - chunkSize: 4 |
7 |
| - uploadDate: { "$date" : "1970-01-01T00:00:00.000Z" } |
8 |
| - md5: "d41d8cd98f00b204e9800998ecf8427e" |
9 |
| - filename: "length-0" |
10 |
| - contentType: "application/octet-stream" |
11 |
| - aliases: [] |
12 |
| - metadata: {} |
13 |
| - - |
14 |
| - _id: { "$oid" : "000000000000000000000002" } |
15 |
| - length: 0 |
16 |
| - chunkSize: 4 |
17 |
| - uploadDate: { "$date" : "1970-01-01T00:00:00.000Z" } |
18 |
| - md5: "d41d8cd98f00b204e9800998ecf8427e" |
19 |
| - filename: "length-0-with-empty-chunk" |
20 |
| - contentType: "application/octet-stream" |
21 |
| - aliases: [] |
22 |
| - metadata: {} |
23 |
| - - |
24 |
| - _id: { "$oid" : "000000000000000000000003" } |
25 |
| - length: 2 |
26 |
| - chunkSize: 4 |
27 |
| - uploadDate: { "$date" : "1970-01-01T00:00:00.000Z" } |
28 |
| - md5: "c700ed4fdb1d27055aa3faa2c2432283" |
29 |
| - filename: "length-2" |
30 |
| - contentType: "application/octet-stream" |
31 |
| - aliases: [] |
32 |
| - metadata: {} |
33 |
| - - |
34 |
| - _id: { "$oid" : "000000000000000000000004" } |
35 |
| - length: 8 |
36 |
| - chunkSize: 4 |
37 |
| - uploadDate: { "$date" : "1970-01-01T00:00:00.000Z" } |
38 |
| - md5: "dd254cdc958e53abaa67da9f797125f5" |
39 |
| - filename: "length-8" |
40 |
| - contentType: "application/octet-stream" |
41 |
| - aliases: [] |
42 |
| - metadata: {} |
43 |
| - chunks: |
44 |
| - - { _id : { "$oid" : "000000000000000000000001" }, files_id : { "$oid" : "000000000000000000000002" }, n : 0, data : { $hex : "" } } |
45 |
| - - { _id : { "$oid" : "000000000000000000000002" }, files_id : { "$oid" : "000000000000000000000003" }, n : 0, data : { $hex : "1122" } } |
46 |
| - - { _id : { "$oid" : "000000000000000000000003" }, files_id : { "$oid" : "000000000000000000000004" }, n : 0, data : { $hex : "11223344" } } |
47 |
| - - { _id : { "$oid" : "000000000000000000000004" }, files_id : { "$oid" : "000000000000000000000004" }, n : 1, data : { $hex : "55667788" } } |
| 1 | +description: "gridfs-delete" |
| 2 | + |
| 3 | +schemaVersion: "1.0" |
| 4 | + |
| 5 | +createEntities: |
| 6 | + - client: |
| 7 | + id: &client0 client0 |
| 8 | + - database: |
| 9 | + id: &database0 database0 |
| 10 | + client: *client0 |
| 11 | + databaseName: &database0Name gridfs-tests |
| 12 | + - bucket: |
| 13 | + id: &bucket0 bucket0 |
| 14 | + database: *database0 |
| 15 | + - collection: |
| 16 | + id: &bucket0_files_collection bucket0_files_collection |
| 17 | + database: *database0 |
| 18 | + collectionName: &bucket0_files_collectionName fs.files |
| 19 | + - collection: |
| 20 | + id: &bucket0_chunks_collection bucket0_chunks_collection |
| 21 | + database: *database0 |
| 22 | + collectionName: &bucket0_chunks_collectionName fs.chunks |
| 23 | + |
| 24 | +initialData: |
| 25 | + - collectionName: *bucket0_files_collectionName |
| 26 | + databaseName: *database0Name |
| 27 | + documents: |
| 28 | + - &file1 |
| 29 | + _id: { "$oid": "000000000000000000000001" } |
| 30 | + length: 0 |
| 31 | + chunkSize: 4 |
| 32 | + uploadDate: { "$date": "1970-01-01T00:00:00.000Z" } |
| 33 | + filename: "length-0" |
| 34 | + metadata: {} |
| 35 | + - &file2 |
| 36 | + _id: { "$oid": "000000000000000000000002" } |
| 37 | + length: 0 |
| 38 | + chunkSize: 4 |
| 39 | + uploadDate: { "$date": "1970-01-01T00:00:00.000Z" } |
| 40 | + filename: "length-0-with-empty-chunk" |
| 41 | + metadata: {} |
| 42 | + - &file3 |
| 43 | + _id: { "$oid": "000000000000000000000003" } |
| 44 | + length: 2 |
| 45 | + chunkSize: 4 |
| 46 | + uploadDate: { "$date": "1970-01-01T00:00:00.000Z" } |
| 47 | + filename: "length-2" |
| 48 | + metadata: {} |
| 49 | + - &file4 |
| 50 | + _id: { "$oid": "000000000000000000000004" } |
| 51 | + length: 8 |
| 52 | + chunkSize: 4 |
| 53 | + uploadDate: { "$date": "1970-01-01T00:00:00.000Z" } |
| 54 | + filename: "length-8" |
| 55 | + metadata: {} |
| 56 | + - collectionName: *bucket0_chunks_collectionName |
| 57 | + databaseName: *database0Name |
| 58 | + documents: |
| 59 | + - &file2_chunk0 |
| 60 | + _id: { "$oid": "000000000000000000000001" } |
| 61 | + files_id: { "$oid": "000000000000000000000002" } |
| 62 | + n: 0 |
| 63 | + data: { "$binary": { "base64": "", "subType": "00" } } |
| 64 | + - &file3_chunk0 |
| 65 | + _id: { "$oid": "000000000000000000000002" } |
| 66 | + files_id: { "$oid": "000000000000000000000003" } |
| 67 | + n: 0 |
| 68 | + data: { "$binary": { "base64": "ESI=", "subType": "00" } } # hex: 1122 |
| 69 | + - &file4_chunk0 |
| 70 | + _id: { "$oid": "000000000000000000000003" } |
| 71 | + files_id: { "$oid": "000000000000000000000004" } |
| 72 | + n: 0 |
| 73 | + data: { "$binary": { "base64": "ESIzRA==", "subType": "00" } } # hex: 11223344 |
| 74 | + - &file4_chunk1 |
| 75 | + _id: { "$oid": "000000000000000000000004" } |
| 76 | + files_id: { "$oid": "000000000000000000000004" } |
| 77 | + n: 1 |
| 78 | + data: { "$binary": { "base64": "VWZ3iA==", "subType": "00" } } # hex: 55667788 |
48 | 79 |
|
49 | 80 | tests:
|
50 |
| - - |
51 |
| - description: "Delete when length is 0" |
52 |
| - act: |
53 |
| - operation: delete |
54 |
| - arguments: |
55 |
| - id: { "$oid" : "000000000000000000000001" } |
56 |
| - assert: |
57 |
| - result: void |
58 |
| - data: |
59 |
| - - |
60 |
| - { delete : "expected.files", deletes : [ |
61 |
| - { q : { _id : { "$oid" : "000000000000000000000001" } }, limit : 1 } |
62 |
| - ] } |
63 |
| - - |
64 |
| - description: "Delete when length is 0 and there is one extra empty chunk" |
65 |
| - act: |
66 |
| - operation: delete |
67 |
| - arguments: |
68 |
| - id: { "$oid" : "000000000000000000000002" } |
69 |
| - assert: |
70 |
| - result: void |
71 |
| - data: |
72 |
| - - |
73 |
| - { delete : "expected.files", deletes : [ |
74 |
| - { q : { _id : { "$oid" : "000000000000000000000002" } }, limit : 1 } |
75 |
| - ] } |
76 |
| - - |
77 |
| - { delete : "expected.chunks", deletes : [ |
78 |
| - { q : { files_id : { "$oid" : "000000000000000000000002" } }, limit : 0 } |
79 |
| - ] } |
80 |
| - - |
81 |
| - description: "Delete when length is 8" |
82 |
| - act: |
83 |
| - operation: delete |
84 |
| - arguments: |
85 |
| - id: { "$oid" : "000000000000000000000004" } |
86 |
| - assert: |
87 |
| - result: void |
88 |
| - data: |
89 |
| - - |
90 |
| - { delete : "expected.files", deletes : [ |
91 |
| - { q : { _id : { "$oid" : "000000000000000000000004" } }, limit : 1 } |
92 |
| - ] } |
93 |
| - - |
94 |
| - { delete : "expected.chunks", deletes : [ |
95 |
| - { q : { files_id : { "$oid" : "000000000000000000000004" } }, limit : 0 } |
96 |
| - ] } |
97 |
| - - |
98 |
| - description: "Delete when files entry does not exist" |
99 |
| - act: |
100 |
| - operation: delete |
101 |
| - arguments: |
102 |
| - id: { "$oid" : "000000000000000000000000" } |
103 |
| - assert: |
104 |
| - error: "FileNotFound" |
105 |
| - - |
106 |
| - description: "Delete when files entry does not exist and there are orphaned chunks" |
107 |
| - arrange: |
108 |
| - data: |
109 |
| - - |
110 |
| - { delete : "fs.files", deletes : [ |
111 |
| - { q : { _id : { "$oid" : "000000000000000000000004" } }, limit : 1 } |
112 |
| - ] } |
113 |
| - act: |
114 |
| - operation: delete |
115 |
| - arguments: |
116 |
| - id: { "$oid" : "000000000000000000000004" } |
117 |
| - assert: |
118 |
| - error: "FileNotFound" |
119 |
| - data: |
120 |
| - - |
121 |
| - { delete : "expected.files", deletes : [ |
122 |
| - { q : { _id : { "$oid" : "000000000000000000000004" } }, limit : 1 } |
123 |
| - ] } |
124 |
| - - |
125 |
| - { delete : "expected.chunks", deletes : [ |
126 |
| - { q : { files_id : { "$oid" : "000000000000000000000004" } }, limit : 0 } |
127 |
| - ] } |
| 81 | + - description: "delete when length is 0" |
| 82 | + operations: |
| 83 | + - name: delete |
| 84 | + object: *bucket0 |
| 85 | + arguments: |
| 86 | + id: { $oid: "000000000000000000000001" } |
| 87 | + outcome: |
| 88 | + - collectionName: *bucket0_files_collectionName |
| 89 | + databaseName: *database0Name |
| 90 | + documents: |
| 91 | + - *file2 |
| 92 | + - *file3 |
| 93 | + - *file4 |
| 94 | + - collectionName: *bucket0_chunks_collectionName |
| 95 | + databaseName: *database0Name |
| 96 | + documents: |
| 97 | + - *file2_chunk0 |
| 98 | + - *file3_chunk0 |
| 99 | + - *file4_chunk0 |
| 100 | + - *file4_chunk1 |
| 101 | + - description: "delete when length is 0 and there is one extra empty chunk" |
| 102 | + operations: |
| 103 | + - name: delete |
| 104 | + object: *bucket0 |
| 105 | + arguments: |
| 106 | + id: { $oid: "000000000000000000000002" } |
| 107 | + outcome: |
| 108 | + - collectionName: *bucket0_files_collectionName |
| 109 | + databaseName: *database0Name |
| 110 | + documents: |
| 111 | + - *file1 |
| 112 | + - *file3 |
| 113 | + - *file4 |
| 114 | + - collectionName: *bucket0_chunks_collectionName |
| 115 | + databaseName: *database0Name |
| 116 | + documents: |
| 117 | + - *file3_chunk0 |
| 118 | + - *file4_chunk0 |
| 119 | + - *file4_chunk1 |
| 120 | + - description: "delete when length is 8" |
| 121 | + operations: |
| 122 | + - name: delete |
| 123 | + object: *bucket0 |
| 124 | + arguments: |
| 125 | + id: { $oid: "000000000000000000000004" } |
| 126 | + outcome: |
| 127 | + - collectionName: *bucket0_files_collectionName |
| 128 | + databaseName: *database0Name |
| 129 | + documents: |
| 130 | + - *file1 |
| 131 | + - *file2 |
| 132 | + - *file3 |
| 133 | + - collectionName: *bucket0_chunks_collectionName |
| 134 | + databaseName: *database0Name |
| 135 | + documents: |
| 136 | + - *file2_chunk0 |
| 137 | + - *file3_chunk0 |
| 138 | + - description: "delete when files entry does not exist" |
| 139 | + operations: |
| 140 | + - name: delete |
| 141 | + object: *bucket0 |
| 142 | + arguments: |
| 143 | + id: { $oid: "000000000000000000000000" } |
| 144 | + expectError: { isError: true } # FileNotFound |
| 145 | + outcome: |
| 146 | + - collectionName: *bucket0_files_collectionName |
| 147 | + databaseName: *database0Name |
| 148 | + documents: |
| 149 | + - *file1 |
| 150 | + - *file2 |
| 151 | + - *file3 |
| 152 | + - *file4 |
| 153 | + - collectionName: *bucket0_chunks_collectionName |
| 154 | + databaseName: *database0Name |
| 155 | + documents: |
| 156 | + - *file2_chunk0 |
| 157 | + - *file3_chunk0 |
| 158 | + - *file4_chunk0 |
| 159 | + - *file4_chunk1 |
| 160 | + - description: "delete when files entry does not exist and there are orphaned chunks" |
| 161 | + operations: |
| 162 | + - name: deleteOne |
| 163 | + object: *bucket0_files_collection |
| 164 | + arguments: |
| 165 | + filter: |
| 166 | + _id: { $oid: "000000000000000000000004" } |
| 167 | + expectResult: |
| 168 | + deletedCount: 1 |
| 169 | + - name: delete |
| 170 | + object: *bucket0 |
| 171 | + arguments: |
| 172 | + id: { $oid: "000000000000000000000004" } |
| 173 | + expectError: { isError: true } # FileNotFound |
| 174 | + outcome: |
| 175 | + - collectionName: *bucket0_files_collectionName |
| 176 | + databaseName: *database0Name |
| 177 | + documents: |
| 178 | + - *file1 |
| 179 | + - *file2 |
| 180 | + - *file3 |
| 181 | + # Orphaned chunks are still deleted even if fs.files |
| 182 | + - collectionName: *bucket0_chunks_collectionName |
| 183 | + databaseName: *database0Name |
| 184 | + documents: |
| 185 | + - *file2_chunk0 |
| 186 | + - *file3_chunk0 |
0 commit comments