Skip to content

Commit

Permalink
DRIVERS-2124: test that inserts and upserts respect null _id values
Browse files Browse the repository at this point in the history
  • Loading branch information
nbbeeken committed Oct 29, 2024
1 parent 9058491 commit ca4d811
Show file tree
Hide file tree
Showing 5 changed files with 453 additions and 7 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/json-regenerate-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,18 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v5
with:
python-version: 3.7
python-version: '3.x'
- name: Set up npm
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: 12
node-version: lts/*
- name: Install dependencies
run: |
npm init -y && npm install js-yaml
npm install -g js-yaml
pip3 install pymongo pyyaml jinja2
- name: Regenerate JSON test files
Expand All @@ -31,8 +32,8 @@ jobs:
python3 ./source/client-side-encryption/etc/generate-test.py ./source/client-side-encryption/etc/test-templates/*.template ./source/client-side-encryption/tests/legacy
python3 ./source/client-side-operations-timeout/etc/generate-basic-tests.py ./source/client-side-operations-timeout/etc/templates ./source/client-side-operations-timeout/tests
python3 ./source/etc/generate-handshakeError-tests.py
node ./source/etc/generate-crud-id-type-tests.mjs
cd source && make -B
- name: "Commit the changes"
uses: stefanzweifel/git-auto-commit-action@v5
with:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ docs_build
.pytest_cache
node_modules
package-lock.json
site
package.json
site
283 changes: 283 additions & 0 deletions source/crud/tests/unified/create-id-types.json

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

57 changes: 57 additions & 0 deletions source/crud/tests/unified/create-id-types.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
description: CRUD ID Type Tests
schemaVersion: '1.0'
createEntities:
- client:
id: client
observeEvents: [commandStartedEvent]
- database:
id: database
client: client
databaseName: crud_id
- collection:
id: collection
database: database
collectionName: type_tests
tests:
- description: inserting _id with type null via insertOne
operations:
- {name: dropCollection, object: database, arguments: {collection: type_tests}}
- {name: insertOne, object: collection, arguments: {document: {_id: null}}}
outcome:
- {databaseName: crud_id, collectionName: type_tests, documents: [{_id: null}]}
- description: inserting _id with type null via insertMany
operations:
- {name: dropCollection, object: database, arguments: {collection: type_tests}}
- {name: insertMany, object: collection, arguments: {documents: [{_id: null}]}}
outcome:
- {databaseName: crud_id, collectionName: type_tests, documents: [{_id: null}]}
- description: inserting _id with type null via updateOne
operations:
- {name: dropCollection, object: database, arguments: {collection: type_tests}}
- {name: updateOne, object: collection, arguments: {filter: {_id: null}, update: {$unset: {a: ''}}, upsert: true}}
outcome:
- {databaseName: crud_id, collectionName: type_tests, documents: [{_id: null}]}
- description: inserting _id with type null via updateMany
operations:
- {name: dropCollection, object: database, arguments: {collection: type_tests}}
- {name: updateMany, object: collection, arguments: {filter: {_id: null}, update: {$unset: {a: ''}}, upsert: true}}
outcome:
- {databaseName: crud_id, collectionName: type_tests, documents: [{_id: null}]}
- description: inserting _id with type null via replaceOne
operations:
- {name: dropCollection, object: database, arguments: {collection: type_tests}}
- {name: replaceOne, object: collection, arguments: {filter: {}, replacement: {_id: null}, upsert: true}}
outcome:
- {databaseName: crud_id, collectionName: type_tests, documents: [{_id: null}]}
- description: inserting _id with type null via bulkWrite
operations:
- {name: dropCollection, object: database, arguments: {collection: type_tests}}
- {name: bulkWrite, object: collection, arguments: {requests: [{insertOne: {document: {_id: null}}}]}}
outcome:
- {databaseName: crud_id, collectionName: type_tests, documents: [{_id: null}]}
- description: inserting _id with type null via clientBulkWrite
operations:
- {name: dropCollection, object: database, arguments: {collection: type_tests}}
- {name: clientBulkWrite, object: client, arguments: {models: [{namespace: crud_id.type_tests, insertOne: {document: {_id: null}}}]}}
outcome:
- {databaseName: crud_id, collectionName: type_tests, documents: [{_id: null}]}
Loading

0 comments on commit ca4d811

Please sign in to comment.