Skip to content

Commit 493283c

Browse files
committed
test: sync gridfs to latest
1 parent 5326ce8 commit 493283c

File tree

7 files changed

+1025
-0
lines changed

7 files changed

+1025
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
import { loadSpecTests } from '../../spec';
22
import { runUnifiedSuite } from '../../tools/unified-spec-runner/runner';
33

4+
const SKIP = [
5+
'delete when multiple revisions of the file exist',
6+
'delete when file name does not exist',
7+
'rename when multiple revisions of the file exist',
8+
'rename when file name does not exist'
9+
];
10+
411
describe('GridFS Unified Tests', function () {
512
runUnifiedSuite(loadSpecTests('gridfs'), ({ description }) => {
13+
if (SKIP.includes(description)) {
14+
return 'TODO(NODE-6511): Implement rename GridFS functionality';
15+
}
616
return description === 'download when final chunk is missing' ? `TODO(NODE-xxxx)` : false;
717
});
818
});

test/spec/gridfs/deleteByName.json

Lines changed: 230 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,230 @@
1+
{
2+
"description": "gridfs-deleteByName",
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": "000000000000000000000001"
46+
},
47+
"length": 0,
48+
"chunkSize": 4,
49+
"uploadDate": {
50+
"$date": "1970-01-01T00:00:00.000Z"
51+
},
52+
"filename": "filename",
53+
"metadata": {}
54+
},
55+
{
56+
"_id": {
57+
"$oid": "000000000000000000000002"
58+
},
59+
"length": 0,
60+
"chunkSize": 4,
61+
"uploadDate": {
62+
"$date": "1970-01-01T00:00:00.000Z"
63+
},
64+
"filename": "filename",
65+
"metadata": {}
66+
},
67+
{
68+
"_id": {
69+
"$oid": "000000000000000000000003"
70+
},
71+
"length": 2,
72+
"chunkSize": 4,
73+
"uploadDate": {
74+
"$date": "1970-01-01T00:00:00.000Z"
75+
},
76+
"filename": "filename",
77+
"metadata": {}
78+
},
79+
{
80+
"_id": {
81+
"$oid": "000000000000000000000004"
82+
},
83+
"length": 8,
84+
"chunkSize": 4,
85+
"uploadDate": {
86+
"$date": "1970-01-01T00:00:00.000Z"
87+
},
88+
"filename": "otherfilename",
89+
"metadata": {}
90+
}
91+
]
92+
},
93+
{
94+
"collectionName": "fs.chunks",
95+
"databaseName": "gridfs-tests",
96+
"documents": [
97+
{
98+
"_id": {
99+
"$oid": "000000000000000000000001"
100+
},
101+
"files_id": {
102+
"$oid": "000000000000000000000002"
103+
},
104+
"n": 0,
105+
"data": {
106+
"$binary": {
107+
"base64": "",
108+
"subType": "00"
109+
}
110+
}
111+
},
112+
{
113+
"_id": {
114+
"$oid": "000000000000000000000002"
115+
},
116+
"files_id": {
117+
"$oid": "000000000000000000000003"
118+
},
119+
"n": 0,
120+
"data": {
121+
"$binary": {
122+
"base64": "",
123+
"subType": "00"
124+
}
125+
}
126+
},
127+
{
128+
"_id": {
129+
"$oid": "000000000000000000000003"
130+
},
131+
"files_id": {
132+
"$oid": "000000000000000000000003"
133+
},
134+
"n": 0,
135+
"data": {
136+
"$binary": {
137+
"base64": "",
138+
"subType": "00"
139+
}
140+
}
141+
},
142+
{
143+
"_id": {
144+
"$oid": "000000000000000000000004"
145+
},
146+
"files_id": {
147+
"$oid": "000000000000000000000004"
148+
},
149+
"n": 0,
150+
"data": {
151+
"$binary": {
152+
"base64": "",
153+
"subType": "00"
154+
}
155+
}
156+
}
157+
]
158+
}
159+
],
160+
"tests": [
161+
{
162+
"description": "delete when multiple revisions of the file exist",
163+
"operations": [
164+
{
165+
"name": "deleteByName",
166+
"object": "bucket0",
167+
"arguments": {
168+
"filename": "filename"
169+
}
170+
}
171+
],
172+
"outcome": [
173+
{
174+
"collectionName": "fs.files",
175+
"databaseName": "gridfs-tests",
176+
"documents": [
177+
{
178+
"_id": {
179+
"$oid": "000000000000000000000004"
180+
},
181+
"length": 8,
182+
"chunkSize": 4,
183+
"uploadDate": {
184+
"$date": "1970-01-01T00:00:00.000Z"
185+
},
186+
"filename": "otherfilename",
187+
"metadata": {}
188+
}
189+
]
190+
},
191+
{
192+
"collectionName": "fs.chunks",
193+
"databaseName": "gridfs-tests",
194+
"documents": [
195+
{
196+
"_id": {
197+
"$oid": "000000000000000000000004"
198+
},
199+
"files_id": {
200+
"$oid": "000000000000000000000004"
201+
},
202+
"n": 0,
203+
"data": {
204+
"$binary": {
205+
"base64": "",
206+
"subType": "00"
207+
}
208+
}
209+
}
210+
]
211+
}
212+
]
213+
},
214+
{
215+
"description": "delete when file name does not exist",
216+
"operations": [
217+
{
218+
"name": "deleteByName",
219+
"object": "bucket0",
220+
"arguments": {
221+
"filename": "missing-file"
222+
},
223+
"expectError": {
224+
"isClientError": true
225+
}
226+
}
227+
]
228+
}
229+
]
230+
}

test/spec/gridfs/deleteByName.yml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
description: "gridfs-deleteByName"
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: "filename"
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: "filename"
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: "filename"
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: "otherfilename"
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": "", "subType": "00" } }
69+
- &file3_chunk1
70+
_id: { "$oid": "000000000000000000000003" }
71+
files_id: { "$oid": "000000000000000000000003" }
72+
n: 0
73+
data: { "$binary": { "base64": "", "subType": "00" } }
74+
- &file4_chunk0
75+
_id: { "$oid": "000000000000000000000004" }
76+
files_id: { "$oid": "000000000000000000000004" }
77+
n: 0
78+
data: { "$binary": { "base64": "", "subType": "00" } }
79+
80+
tests:
81+
- description: "delete when multiple revisions of the file exist"
82+
operations:
83+
- name: deleteByName
84+
object: *bucket0
85+
arguments:
86+
filename: filename
87+
outcome:
88+
- collectionName: *bucket0_files_collectionName
89+
databaseName: *database0Name
90+
documents:
91+
- <<: *file4
92+
- collectionName: *bucket0_chunks_collectionName
93+
databaseName: *database0Name
94+
documents:
95+
- *file4_chunk0
96+
- description: "delete when file name does not exist"
97+
operations:
98+
- name: deleteByName
99+
object: *bucket0
100+
arguments:
101+
filename: missing-file
102+
expectError: { isClientError: true } # FileNotFound

0 commit comments

Comments
 (0)