Added index type tests for single#253
Conversation
Signed-off-by: Victor [C] Tsang <vitsangp@amazon.com>
|
🤖 Auto-triaged by documentdb-triage-tool. Applied: Reasoningcomponent from path globs (test-coverage); effort from diff stats (506+0 LOC, 6 files); LLM: Adds new index type test cases for single indexes under the compatibility test suite, referencing issue #27. If a label is wrong, remove it manually and ping |
| default_error_code=CANNOT_CREATE_INDEX_ERROR, | ||
| valid_inputs={ | ||
| BsonType.DOUBLE: 1.0, | ||
| BsonType.INT: 1, |
| assertSuccessPartial(result, index_created_response(), test.msg) | ||
|
|
||
|
|
||
| def test_single_creation_on_nonexistent_collection(collection): |
| ) | ||
| collection.insert_many(list(test.doc)) | ||
| result = execute_command(collection, {"find": collection.name, "filter": test.filter}) | ||
| assertSuccess(result, test.expected, msg=test.msg) |
| collection, | ||
| {"find": collection.name, "filter": {"a": 10}, "projection": {"_id": 0, "a": 1}}, | ||
| ) | ||
| assertSuccess(result, [{"a": 10}], msg="Should return only indexed field") |
There was a problem hiding this comment.
non of the assert actually assert index usage.
| result, | ||
| INDEX_KEY_SPECS_CONFLICT_ERROR, | ||
| msg="Same key+name with different options should fail", | ||
| ) |
There was a problem hiding this comment.
where are partial index , sparse and hidden properties tested for index creation success and failure.
| collection, | ||
| {"find": collection.name, "filter": {"a": 10}, "projection": {"_id": 0, "a": 1, "b": 1}}, | ||
| ) | ||
| assertSuccess(result, [{"a": 10, "b": "x"}], msg="Should return indexed and non-indexed fields") |
There was a problem hiding this comment.
Missing: $in and $ne queries - these also are used as index filter condition.
Missing: hint usage
| ] | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("test", pytest_params(CREATION_ERROR_TESTS)) |
| result, | ||
| {"ok": 1.0, "numIndexesBefore": 2, "numIndexesAfter": 3}, | ||
| msg="Different sort order should create separate index", | ||
| ) |
| indexes=({"key": {"a.b": 1}, "name": "a.b_1"},), | ||
| msg="Dot notation field succeeds", | ||
| ), | ||
| ] |
There was a problem hiding this comment.
Missing: multiple fields in a single createIndexes call.
This PR contains:
Note: I realized a lot of tests already exists in createIndexes. It might seem like we are missing some tests but they could be covered already in createIndexes. Rather than having duplicated tests I have omitted them.
Ref: