description: "server-connection-id"

schemaVersion: "1.6"

runOnRequirements:
  - minServerVersion: "4.2"

createEntities:
  - client:
      id: &client client
      observeEvents:
        - commandStartedEvent
        - commandSucceededEvent
        - commandFailedEvent
  - database:
      id: &database database
      client: *client
      databaseName: &databaseName server-connection-id-tests
  - collection:
      id: &collection collection
      database: *database
      collectionName: &collectionName coll

initialData:
  - databaseName: *databaseName
    collectionName: *collectionName
    documents: []

tests:
  - description: "command events include server connection id"
    operations:
      - name: insertOne
        object: *collection
        arguments:
            document: { x: 1 }
      - name: find
        object: *collection
        arguments:
          filter: { $or: true }
        expectError:
          isError: true
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: insert
              hasServerConnectionId: true
          - commandSucceededEvent:
              commandName: insert
              hasServerConnectionId: true
          - commandStartedEvent:
              commandName: find
              hasServerConnectionId: true
          - commandFailedEvent:
              commandName: find
              hasServerConnectionId: true
