{
  "description": "client bulkWrite with mixed namespaces",
  "schemaVersion": "1.4",
  "runOnRequirements": [
    {
      "minServerVersion": "8.0",
      "serverless": "forbid"
    }
  ],
  "createEntities": [
    {
      "client": {
        "id": "client0",
        "observeEvents": [
          "commandStartedEvent"
        ]
      }
    },
    {
      "database": {
        "id": "database0",
        "client": "client0",
        "databaseName": "db0"
      }
    },
    {
      "collection": {
        "id": "collection0",
        "database": "database0",
        "collectionName": "coll0"
      }
    },
    {
      "collection": {
        "id": "collection1",
        "database": "database0",
        "collectionName": "coll1"
      }
    },
    {
      "database": {
        "id": "database1",
        "client": "client0",
        "databaseName": "db1"
      }
    },
    {
      "collection": {
        "id": "collection2",
        "database": "database1",
        "collectionName": "coll2"
      }
    }
  ],
  "initialData": [
    {
      "databaseName": "db0",
      "collectionName": "coll0",
      "documents": []
    },
    {
      "databaseName": "db0",
      "collectionName": "coll1",
      "documents": [
        {
          "_id": 1,
          "x": 11
        },
        {
          "_id": 2,
          "x": 22
        }
      ]
    },
    {
      "databaseName": "db1",
      "collectionName": "coll2",
      "documents": [
        {
          "_id": 3,
          "x": 33
        },
        {
          "_id": 4,
          "x": 44
        }
      ]
    }
  ],
  "_yamlAnchors": {
    "db0Coll0Namespace": "db0.coll0",
    "db0Coll1Namespace": "db0.coll1",
    "db1Coll2Namespace": "db1.coll2"
  },
  "tests": [
    {
      "description": "client bulkWrite with mixed namespaces",
      "operations": [
        {
          "object": "client0",
          "name": "clientBulkWrite",
          "arguments": {
            "models": [
              {
                "insertOne": {
                  "namespace": "db0.coll0",
                  "document": {
                    "_id": 1
                  }
                }
              },
              {
                "insertOne": {
                  "namespace": "db0.coll0",
                  "document": {
                    "_id": 2
                  }
                }
              },
              {
                "updateOne": {
                  "namespace": "db0.coll1",
                  "filter": {
                    "_id": 1
                  },
                  "update": {
                    "$inc": {
                      "x": 1
                    }
                  }
                }
              },
              {
                "deleteOne": {
                  "namespace": "db1.coll2",
                  "filter": {
                    "_id": 3
                  }
                }
              },
              {
                "deleteOne": {
                  "namespace": "db0.coll1",
                  "filter": {
                    "_id": 2
                  }
                }
              },
              {
                "replaceOne": {
                  "namespace": "db1.coll2",
                  "filter": {
                    "_id": 4
                  },
                  "replacement": {
                    "x": 45
                  }
                }
              }
            ],
            "verboseResults": true
          },
          "expectResult": {
            "insertedCount": 2,
            "upsertedCount": 0,
            "matchedCount": 2,
            "modifiedCount": 2,
            "deletedCount": 2,
            "insertResults": {
              "0": {
                "insertedId": 1
              },
              "1": {
                "insertedId": 2
              }
            },
            "updateResults": {
              "2": {
                "matchedCount": 1,
                "modifiedCount": 1,
                "upsertedId": {
                  "$$exists": false
                }
              },
              "5": {
                "matchedCount": 1,
                "modifiedCount": 1,
                "upsertedId": {
                  "$$exists": false
                }
              }
            },
            "deleteResults": {
              "3": {
                "deletedCount": 1
              },
              "4": {
                "deletedCount": 1
              }
            }
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client0",
          "events": [
            {
              "commandStartedEvent": {
                "command": {
                  "bulkWrite": 1,
                  "ops": [
                    {
                      "insert": 0,
                      "document": {
                        "_id": 1
                      }
                    },
                    {
                      "insert": 0,
                      "document": {
                        "_id": 2
                      }
                    },
                    {
                      "update": 1,
                      "filter": {
                        "_id": 1
                      },
                      "updateMods": {
                        "$inc": {
                          "x": 1
                        }
                      },
                      "multi": false
                    },
                    {
                      "delete": 2,
                      "filter": {
                        "_id": 3
                      },
                      "multi": false
                    },
                    {
                      "delete": 1,
                      "filter": {
                        "_id": 2
                      },
                      "multi": false
                    },
                    {
                      "update": 2,
                      "filter": {
                        "_id": 4
                      },
                      "updateMods": {
                        "x": 45
                      },
                      "multi": false
                    }
                  ],
                  "nsInfo": [
                    {
                      "ns": "db0.coll0"
                    },
                    {
                      "ns": "db0.coll1"
                    },
                    {
                      "ns": "db1.coll2"
                    }
                  ]
                }
              }
            }
          ]
        }
      ],
      "outcome": [
        {
          "databaseName": "db0",
          "collectionName": "coll0",
          "documents": [
            {
              "_id": 1
            },
            {
              "_id": 2
            }
          ]
        },
        {
          "databaseName": "db0",
          "collectionName": "coll1",
          "documents": [
            {
              "_id": 1,
              "x": 12
            }
          ]
        },
        {
          "databaseName": "db1",
          "collectionName": "coll2",
          "documents": [
            {
              "_id": 4,
              "x": 45
            }
          ]
        }
      ]
    }
  ]
}
