{
  "description": "client bulkWrite partial results",
  "schemaVersion": "1.4",
  "runOnRequirements": [
    {
      "minServerVersion": "8.0",
      "serverless": "forbid"
    }
  ],
  "createEntities": [
    {
      "client": {
        "id": "client0"
      }
    },
    {
      "database": {
        "id": "database0",
        "client": "client0",
        "databaseName": "crud-tests"
      }
    },
    {
      "collection": {
        "id": "collection0",
        "database": "database0",
        "collectionName": "coll0"
      }
    }
  ],
  "initialData": [
    {
      "collectionName": "coll0",
      "databaseName": "crud-tests",
      "documents": [
        {
          "_id": 1,
          "x": 11
        }
      ]
    }
  ],
  "_yamlAnchors": {
    "namespace": "crud-tests.coll0",
    "newDocument": {
      "_id": 2,
      "x": 22
    }
  },
  "tests": [
    {
      "description": "partialResult is unset when first operation fails during an ordered bulk write (verbose)",
      "operations": [
        {
          "object": "client0",
          "name": "clientBulkWrite",
          "arguments": {
            "models": [
              {
                "insertOne": {
                  "namespace": "crud-tests.coll0",
                  "document": {
                    "_id": 1,
                    "x": 11
                  }
                }
              },
              {
                "insertOne": {
                  "namespace": "crud-tests.coll0",
                  "document": {
                    "_id": 2,
                    "x": 22
                  }
                }
              }
            ],
            "ordered": true,
            "verboseResults": true
          },
          "expectError": {
            "expectResult": {
              "$$unsetOrMatches": {
                "insertedCount": {
                  "$$exists": false
                },
                "upsertedCount": {
                  "$$exists": false
                },
                "matchedCount": {
                  "$$exists": false
                },
                "modifiedCount": {
                  "$$exists": false
                },
                "deletedCount": {
                  "$$exists": false
                },
                "insertResults": {
                  "$$exists": false
                },
                "updateResults": {
                  "$$exists": false
                },
                "deleteResults": {
                  "$$exists": false
                }
              }
            }
          }
        }
      ]
    },
    {
      "description": "partialResult is unset when first operation fails during an ordered bulk write (summary)",
      "operations": [
        {
          "object": "client0",
          "name": "clientBulkWrite",
          "arguments": {
            "models": [
              {
                "insertOne": {
                  "namespace": "crud-tests.coll0",
                  "document": {
                    "_id": 1,
                    "x": 11
                  }
                }
              },
              {
                "insertOne": {
                  "namespace": "crud-tests.coll0",
                  "document": {
                    "_id": 2,
                    "x": 22
                  }
                }
              }
            ],
            "ordered": true,
            "verboseResults": false
          },
          "expectError": {
            "expectResult": {
              "$$unsetOrMatches": {
                "insertedCount": {
                  "$$exists": false
                },
                "upsertedCount": {
                  "$$exists": false
                },
                "matchedCount": {
                  "$$exists": false
                },
                "modifiedCount": {
                  "$$exists": false
                },
                "deletedCount": {
                  "$$exists": false
                },
                "insertResults": {
                  "$$exists": false
                },
                "updateResults": {
                  "$$exists": false
                },
                "deleteResults": {
                  "$$exists": false
                }
              }
            }
          }
        }
      ]
    },
    {
      "description": "partialResult is set when second operation fails during an ordered bulk write (verbose)",
      "operations": [
        {
          "object": "client0",
          "name": "clientBulkWrite",
          "arguments": {
            "models": [
              {
                "insertOne": {
                  "namespace": "crud-tests.coll0",
                  "document": {
                    "_id": 2,
                    "x": 22
                  }
                }
              },
              {
                "insertOne": {
                  "namespace": "crud-tests.coll0",
                  "document": {
                    "_id": 1,
                    "x": 11
                  }
                }
              }
            ],
            "ordered": true,
            "verboseResults": true
          },
          "expectError": {
            "expectResult": {
              "insertedCount": 1,
              "upsertedCount": 0,
              "matchedCount": 0,
              "modifiedCount": 0,
              "deletedCount": 0,
              "insertResults": {
                "0": {
                  "insertedId": 2
                }
              },
              "updateResults": {},
              "deleteResults": {}
            }
          }
        }
      ]
    },
    {
      "description": "partialResult is set when second operation fails during an ordered bulk write (summary)",
      "operations": [
        {
          "object": "client0",
          "name": "clientBulkWrite",
          "arguments": {
            "models": [
              {
                "insertOne": {
                  "namespace": "crud-tests.coll0",
                  "document": {
                    "_id": 2,
                    "x": 22
                  }
                }
              },
              {
                "insertOne": {
                  "namespace": "crud-tests.coll0",
                  "document": {
                    "_id": 1,
                    "x": 11
                  }
                }
              }
            ],
            "ordered": true,
            "verboseResults": false
          },
          "expectError": {
            "expectResult": {
              "insertedCount": 1,
              "upsertedCount": 0,
              "matchedCount": 0,
              "modifiedCount": 0,
              "deletedCount": 0,
              "insertResults": {
                "$$unsetOrMatches": {}
              },
              "updateResults": {
                "$$unsetOrMatches": {}
              },
              "deleteResults": {
                "$$unsetOrMatches": {}
              }
            }
          }
        }
      ]
    },
    {
      "description": "partialResult is unset when all operations fail during an unordered bulk write",
      "operations": [
        {
          "object": "client0",
          "name": "clientBulkWrite",
          "arguments": {
            "models": [
              {
                "insertOne": {
                  "namespace": "crud-tests.coll0",
                  "document": {
                    "_id": 1,
                    "x": 11
                  }
                }
              },
              {
                "insertOne": {
                  "namespace": "crud-tests.coll0",
                  "document": {
                    "_id": 1,
                    "x": 11
                  }
                }
              }
            ],
            "ordered": false
          },
          "expectError": {
            "expectResult": {
              "$$unsetOrMatches": {
                "insertedCount": {
                  "$$exists": false
                },
                "upsertedCount": {
                  "$$exists": false
                },
                "matchedCount": {
                  "$$exists": false
                },
                "modifiedCount": {
                  "$$exists": false
                },
                "deletedCount": {
                  "$$exists": false
                },
                "insertResults": {
                  "$$exists": false
                },
                "updateResults": {
                  "$$exists": false
                },
                "deleteResults": {
                  "$$exists": false
                }
              }
            }
          }
        }
      ]
    },
    {
      "description": "partialResult is set when first operation fails during an unordered bulk write (verbose)",
      "operations": [
        {
          "object": "client0",
          "name": "clientBulkWrite",
          "arguments": {
            "models": [
              {
                "insertOne": {
                  "namespace": "crud-tests.coll0",
                  "document": {
                    "_id": 1,
                    "x": 11
                  }
                }
              },
              {
                "insertOne": {
                  "namespace": "crud-tests.coll0",
                  "document": {
                    "_id": 2,
                    "x": 22
                  }
                }
              }
            ],
            "ordered": false,
            "verboseResults": true
          },
          "expectError": {
            "expectResult": {
              "insertedCount": 1,
              "upsertedCount": 0,
              "matchedCount": 0,
              "modifiedCount": 0,
              "deletedCount": 0,
              "insertResults": {
                "1": {
                  "insertedId": 2
                }
              },
              "updateResults": {},
              "deleteResults": {}
            }
          }
        }
      ]
    },
    {
      "description": "partialResult is set when first operation fails during an unordered bulk write (summary)",
      "operations": [
        {
          "object": "client0",
          "name": "clientBulkWrite",
          "arguments": {
            "models": [
              {
                "insertOne": {
                  "namespace": "crud-tests.coll0",
                  "document": {
                    "_id": 1,
                    "x": 11
                  }
                }
              },
              {
                "insertOne": {
                  "namespace": "crud-tests.coll0",
                  "document": {
                    "_id": 2,
                    "x": 22
                  }
                }
              }
            ],
            "ordered": false,
            "verboseResults": false
          },
          "expectError": {
            "expectResult": {
              "insertedCount": 1,
              "upsertedCount": 0,
              "matchedCount": 0,
              "modifiedCount": 0,
              "deletedCount": 0,
              "insertResults": {
                "$$unsetOrMatches": {}
              },
              "updateResults": {
                "$$unsetOrMatches": {}
              },
              "deleteResults": {
                "$$unsetOrMatches": {}
              }
            }
          }
        }
      ]
    },
    {
      "description": "partialResult is set when second operation fails during an unordered bulk write (verbose)",
      "operations": [
        {
          "object": "client0",
          "name": "clientBulkWrite",
          "arguments": {
            "models": [
              {
                "insertOne": {
                  "namespace": "crud-tests.coll0",
                  "document": {
                    "_id": 2,
                    "x": 22
                  }
                }
              },
              {
                "insertOne": {
                  "namespace": "crud-tests.coll0",
                  "document": {
                    "_id": 1,
                    "x": 11
                  }
                }
              }
            ],
            "ordered": false,
            "verboseResults": true
          },
          "expectError": {
            "expectResult": {
              "insertedCount": 1,
              "upsertedCount": 0,
              "matchedCount": 0,
              "modifiedCount": 0,
              "deletedCount": 0,
              "insertResults": {
                "0": {
                  "insertedId": 2
                }
              },
              "updateResults": {},
              "deleteResults": {}
            }
          }
        }
      ]
    },
    {
      "description": "partialResult is set when second operation fails during an unordered bulk write (summary)",
      "operations": [
        {
          "object": "client0",
          "name": "clientBulkWrite",
          "arguments": {
            "models": [
              {
                "insertOne": {
                  "namespace": "crud-tests.coll0",
                  "document": {
                    "_id": 2,
                    "x": 22
                  }
                }
              },
              {
                "insertOne": {
                  "namespace": "crud-tests.coll0",
                  "document": {
                    "_id": 1,
                    "x": 11
                  }
                }
              }
            ],
            "ordered": false,
            "verboseResults": false
          },
          "expectError": {
            "expectResult": {
              "insertedCount": 1,
              "upsertedCount": 0,
              "matchedCount": 0,
              "modifiedCount": 0,
              "deletedCount": 0,
              "insertResults": {
                "$$unsetOrMatches": {}
              },
              "updateResults": {
                "$$unsetOrMatches": {}
              },
              "deleteResults": {
                "$$unsetOrMatches": {}
              }
            }
          }
        }
      ]
    }
  ]
}
