{
  "description": "countDocuments-comment",
  "schemaVersion": "1.0",
  "createEntities": [
    {
      "client": {
        "id": "client0",
        "observeEvents": [
          "commandStartedEvent"
        ]
      }
    },
    {
      "database": {
        "id": "database0",
        "client": "client0",
        "databaseName": "countDocuments-comments-test"
      }
    },
    {
      "collection": {
        "id": "collection0",
        "database": "database0",
        "collectionName": "coll0"
      }
    }
  ],
  "initialData": [
    {
      "collectionName": "coll0",
      "databaseName": "countDocuments-comments-test",
      "documents": [
        {
          "_id": 1,
          "x": 11
        },
        {
          "_id": 2,
          "x": 22
        },
        {
          "_id": 3,
          "x": 33
        }
      ]
    }
  ],
  "tests": [
    {
      "description": "countDocuments with document comment",
      "runOnRequirements": [
        {
          "minServerVersion": "4.4.0"
        }
      ],
      "operations": [
        {
          "name": "countDocuments",
          "object": "collection0",
          "arguments": {
            "filter": {},
            "comment": {
              "key": "value"
            }
          },
          "expectResult": 3
        }
      ],
      "expectEvents": [
        {
          "client": "client0",
          "events": [
            {
              "commandStartedEvent": {
                "command": {
                  "aggregate": "coll0",
                  "pipeline": [
                    {
                      "$match": {}
                    },
                    {
                      "$group": {
                        "_id": 1,
                        "n": {
                          "$sum": 1
                        }
                      }
                    }
                  ],
                  "comment": {
                    "key": "value"
                  }
                },
                "commandName": "aggregate",
                "databaseName": "countDocuments-comments-test"
              }
            }
          ]
        }
      ]
    },
    {
      "description": "countDocuments with string comment",
      "runOnRequirements": [
        {
          "minServerVersion": "3.6.0"
        }
      ],
      "operations": [
        {
          "name": "countDocuments",
          "object": "collection0",
          "arguments": {
            "filter": {},
            "comment": "comment"
          },
          "expectResult": 3
        }
      ],
      "expectEvents": [
        {
          "client": "client0",
          "events": [
            {
              "commandStartedEvent": {
                "command": {
                  "aggregate": "coll0",
                  "pipeline": [
                    {
                      "$match": {}
                    },
                    {
                      "$group": {
                        "_id": 1,
                        "n": {
                          "$sum": 1
                        }
                      }
                    }
                  ],
                  "comment": "comment"
                },
                "commandName": "aggregate",
                "databaseName": "countDocuments-comments-test"
              }
            }
          ]
        }
      ]
    },
    {
      "description": "countDocuments with document comment on less than 4.4.0 - server error",
      "runOnRequirements": [
        {
          "minServerVersion": "3.6.0",
          "maxServerVersion": "4.3.99"
        }
      ],
      "operations": [
        {
          "name": "countDocuments",
          "object": "collection0",
          "arguments": {
            "filter": {},
            "comment": {
              "key": "value"
            }
          },
          "expectError": {
            "isClientError": false
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client0",
          "events": [
            {
              "commandStartedEvent": {
                "command": {
                  "aggregate": "coll0",
                  "pipeline": [
                    {
                      "$match": {}
                    },
                    {
                      "$group": {
                        "_id": 1,
                        "n": {
                          "$sum": 1
                        }
                      }
                    }
                  ],
                  "comment": {
                    "key": "value"
                  }
                },
                "commandName": "aggregate",
                "databaseName": "countDocuments-comments-test"
              }
            }
          ]
        }
      ]
    }
  ]
}
