Skip to content

Commit

Permalink
add index-management tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinAlbs committed Jul 31, 2023
1 parent 4baf28e commit f197dac
Show file tree
Hide file tree
Showing 6 changed files with 687 additions and 0 deletions.
136 changes: 136 additions & 0 deletions src/libmongoc/tests/json/index-management/createSearchIndex.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
{
"description": "createSearchIndex",
"schemaVersion": "1.4",
"createEntities": [
{
"client": {
"id": "client0",
"useMultipleMongoses": false,
"observeEvents": [
"commandStartedEvent"
]
}
},
{
"database": {
"id": "database0",
"client": "client0",
"databaseName": "database0"
}
},
{
"collection": {
"id": "collection0",
"database": "database0",
"collectionName": "collection0"
}
}
],
"runOnRequirements": [
{
"minServerVersion": "7.0.0",
"topologies": [
"replicaset",
"load-balanced",
"sharded"
],
"serverless": "forbid"
}
],
"tests": [
{
"description": "no name provided for an index definition",
"operations": [
{
"name": "createSearchIndex",
"object": "collection0",
"arguments": {
"model": {
"definition": {
"mappings": {
"dynamic": true
}
}
}
},
"expectError": {
"isError": true,
"errorContains": "Search index commands are only supported with Atlas"
}
}
],
"expectEvents": [
{
"client": "client0",
"events": [
{
"commandStartedEvent": {
"command": {
"createSearchIndexes": "collection0",
"indexes": [
{
"definition": {
"mappings": {
"dynamic": true
}
}
}
],
"$db": "database0"
}
}
}
]
}
]
},
{
"description": "name provided for an index definition",
"operations": [
{
"name": "createSearchIndex",
"object": "collection0",
"arguments": {
"model": {
"definition": {
"mappings": {
"dynamic": true
}
},
"name": "test index"
}
},
"expectError": {
"isError": true,
"errorContains": "Search index commands are only supported with Atlas"
}
}
],
"expectEvents": [
{
"client": "client0",
"events": [
{
"commandStartedEvent": {
"command": {
"createSearchIndexes": "collection0",
"indexes": [
{
"definition": {
"mappings": {
"dynamic": true
}
},
"name": "test index"
}
],
"$db": "database0"
}
}
}
]
}
]
}
]
}
172 changes: 172 additions & 0 deletions src/libmongoc/tests/json/index-management/createSearchIndexes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
{
"description": "createSearchIndexes",
"schemaVersion": "1.4",
"createEntities": [
{
"client": {
"id": "client0",
"useMultipleMongoses": false,
"observeEvents": [
"commandStartedEvent"
]
}
},
{
"database": {
"id": "database0",
"client": "client0",
"databaseName": "database0"
}
},
{
"collection": {
"id": "collection0",
"database": "database0",
"collectionName": "collection0"
}
}
],
"runOnRequirements": [
{
"minServerVersion": "7.0.0",
"topologies": [
"replicaset",
"load-balanced",
"sharded"
],
"serverless": "forbid"
}
],
"tests": [
{
"description": "empty index definition array",
"operations": [
{
"name": "createSearchIndexes",
"object": "collection0",
"arguments": {
"models": []
},
"expectError": {
"isError": true,
"errorContains": "Search index commands are only supported with Atlas"
}
}
],
"expectEvents": [
{
"client": "client0",
"events": [
{
"commandStartedEvent": {
"command": {
"createSearchIndexes": "collection0",
"indexes": [],
"$db": "database0"
}
}
}
]
}
]
},
{
"description": "no name provided for an index definition",
"operations": [
{
"name": "createSearchIndexes",
"object": "collection0",
"arguments": {
"models": [
{
"definition": {
"mappings": {
"dynamic": true
}
}
}
]
},
"expectError": {
"isError": true,
"errorContains": "Search index commands are only supported with Atlas"
}
}
],
"expectEvents": [
{
"client": "client0",
"events": [
{
"commandStartedEvent": {
"command": {
"createSearchIndexes": "collection0",
"indexes": [
{
"definition": {
"mappings": {
"dynamic": true
}
}
}
],
"$db": "database0"
}
}
}
]
}
]
},
{
"description": "name provided for an index definition",
"operations": [
{
"name": "createSearchIndexes",
"object": "collection0",
"arguments": {
"models": [
{
"definition": {
"mappings": {
"dynamic": true
}
},
"name": "test index"
}
]
},
"expectError": {
"isError": true,
"errorContains": "Search index commands are only supported with Atlas"
}
}
],
"expectEvents": [
{
"client": "client0",
"events": [
{
"commandStartedEvent": {
"command": {
"createSearchIndexes": "collection0",
"indexes": [
{
"definition": {
"mappings": {
"dynamic": true
}
},
"name": "test index"
}
],
"$db": "database0"
}
}
}
]
}
]
}
]
}
74 changes: 74 additions & 0 deletions src/libmongoc/tests/json/index-management/dropSearchIndex.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"description": "dropSearchIndex",
"schemaVersion": "1.4",
"createEntities": [
{
"client": {
"id": "client0",
"useMultipleMongoses": false,
"observeEvents": [
"commandStartedEvent"
]
}
},
{
"database": {
"id": "database0",
"client": "client0",
"databaseName": "database0"
}
},
{
"collection": {
"id": "collection0",
"database": "database0",
"collectionName": "collection0"
}
}
],
"runOnRequirements": [
{
"minServerVersion": "7.0.0",
"topologies": [
"replicaset",
"load-balanced",
"sharded"
],
"serverless": "forbid"
}
],
"tests": [
{
"description": "sends the correct command",
"operations": [
{
"name": "dropSearchIndex",
"object": "collection0",
"arguments": {
"name": "test index"
},
"expectError": {
"isError": true,
"errorContains": "Search index commands are only supported with Atlas"
}
}
],
"expectEvents": [
{
"client": "client0",
"events": [
{
"commandStartedEvent": {
"command": {
"dropSearchIndex": "collection0",
"name": "test index",
"$db": "database0"
}
}
}
]
}
]
}
]
}
Loading

0 comments on commit f197dac

Please sign in to comment.