# Test that setting a default write concern does not add a write concern
# to the command sent over the wire.
# Test operations that require 4.2+ server.

data:
  - {_id: 1, x: 11}
  - {_id: 2, x: 22}
collection_name: &collection_name default_write_concern_coll
database_name: &database_name default_write_concern_db

runOn:
    - minServerVersion: "4.2"

tests:
  - description: Aggregate with $merge omits default write concern
    operations:
      - object: collection
        databaseOptions: {writeConcern: {}}
        collectionOptions: {writeConcern: {}}
        name: aggregate
        arguments:
          pipeline: &merge_pipeline
            - $match: {_id: {$gt: 1}}
            - $merge: {into: &other_collection_name "other_collection_name" }
    expectations:
      - command_started_event:
          command:
            aggregate: *collection_name
            pipeline: *merge_pipeline
            # "null" fields will be checked for non-existence
            writeConcern: null
    outcome:
      collection:
        name: *other_collection_name
        data:
          - {_id: 2, x: 22}