Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DRIVERS-3023 Add spec tests for GridFS rename and require client errors #1700

Merged
merged 2 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions source/gridfs/gridfs-spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -1042,6 +1042,7 @@ system?") it is a potential area of growth for the future.

## Changelog

- 2024-10-30: Add spec tests for `rename` method
GromNaN marked this conversation as resolved.
Show resolved Hide resolved
- 2024-10-28: Removed deprecated fields from tests: `md5`, `contentType`, `aliases`
- 2024-02-27: Migrated from reStructuredText to Markdown.
- 2016-05-10: Support custom file ids
Expand Down
179 changes: 179 additions & 0 deletions source/gridfs/tests/rename.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

78 changes: 78 additions & 0 deletions source/gridfs/tests/rename.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
description: "gridfs-rename"

schemaVersion: "1.0"

createEntities:
- client:
id: &client0 client0
- database:
id: &database0 database0
client: *client0
databaseName: &database0Name gridfs-tests
- bucket:
id: &bucket0 bucket0
database: *database0
- collection:
id: &bucket0_files_collection bucket0_files_collection
database: *database0
collectionName: &bucket0_files_collectionName fs.files
- collection:
id: &bucket0_chunks_collection bucket0_chunks_collection
database: *database0
collectionName: &bucket0_chunks_collectionName fs.chunks

initialData:
- collectionName: *bucket0_files_collectionName
databaseName: *database0Name
documents:
- &file1
_id: { "$oid": "000000000000000000000001" }
length: 0
chunkSize: 4
uploadDate: { "$date": "1970-01-01T00:00:00.000Z" }
filename: "filename"
metadata: {}
- &file2
_id: { "$oid": "000000000000000000000002" }
length: 0
chunkSize: 4
uploadDate: { "$date": "1970-01-01T00:00:00.000Z" }
filename: "filename"
metadata: {}
- collectionName: *bucket0_chunks_collectionName
databaseName: *database0Name
documents:
- &file2_chunk0
_id: { "$oid": "000000000000000000000001" }
files_id: { "$oid": "000000000000000000000002" }
n: 0
data: { "$binary": { "base64": "", "subType": "00" } }

tests:
- description: "rename by id"
operations:
- name: rename
object: *bucket0
arguments:
id: { "$oid": "000000000000000000000001" }
newFilename: newfilename
outcome:
- collectionName: *bucket0_files_collectionName
databaseName: *database0Name
documents:
- <<: *file1
filename: newfilename
- <<: *file2
filename: filename
- collectionName: *bucket0_chunks_collectionName
databaseName: *database0Name
documents:
- *file2_chunk0
- description: "rename when file id does not exist"
operations:
- name: rename
object: *bucket0
arguments:
id: { "$oid": "000000000000000000000003" }
newFilename: newfilename
expectError: { isError: true } # FileNotFound
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jmikola should this use isClientError: true?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated all the gridfs spec tests to use isClientError, this schemaVersion is not affected.

Loading