...

Text file src/go.mongodb.org/mongo-driver/testdata/read-write-concern/operation/default-write-concern-3.4.yml

Documentation: go.mongodb.org/mongo-driver/testdata/read-write-concern/operation

     1# Test that setting a default write concern does not add a write concern
     2# to the command sent over the wire.
     3# Test operations that require 3.4+ server, where all commands started
     4# to accept a write concern.
     5
     6data:
     7  - {_id: 1, x: 11}
     8  - {_id: 2, x: 22}
     9collection_name: &collection_name default_write_concern_coll
    10database_name: &database_name default_write_concern_db
    11
    12runOn:
    13    - minServerVersion: "3.4"
    14
    15tests:
    16  - description: Aggregate with $out omits default write concern
    17    operations:
    18      - object: collection
    19        collectionOptions: {writeConcern: {}}
    20        name: aggregate
    21        arguments:
    22          pipeline: &out_pipeline
    23            - $match: {_id: {$gt: 1}}
    24            - $out: &other_collection_name "other_collection_name"
    25    outcome:
    26      collection:
    27        name: *other_collection_name
    28        data:
    29          - {_id: 2, x: 22}
    30    expectations:
    31      - command_started_event:
    32          command:
    33            aggregate: *collection_name
    34            pipeline: *out_pipeline
    35            writeConcern: null
    36  - description: RunCommand with a write command omits default write concern (runCommand should never inherit write concern)
    37    operations:
    38      - object: database
    39        databaseOptions: {writeConcern: {}}
    40        name: runCommand
    41        command_name: delete
    42        arguments:
    43          command:
    44            delete: *collection_name
    45            deletes:
    46              - {q: {}, limit: 1}
    47    expectations:
    48      - command_started_event:
    49          command:
    50            delete: *collection_name
    51            deletes:
    52              - {q: {}, limit: 1}
    53            writeConcern: null
    54  - description: CreateIndex and dropIndex omits default write concern 
    55    operations:
    56      - object: collection
    57        collectionOptions: {writeConcern: {}}
    58        name: createIndex
    59        arguments:
    60          keys: {x: 1}
    61      - object: collection
    62        collectionOptions: {writeConcern: {}}
    63        name: dropIndex
    64        arguments:
    65          name: x_1
    66    expectations:
    67      - command_started_event:
    68          command:
    69            createIndexes: *collection_name
    70            indexes:
    71              - name: x_1
    72                key: {x: 1}
    73            writeConcern: null
    74      - command_started_event:
    75          command:
    76            dropIndexes: *collection_name
    77            index: x_1
    78            writeConcern: null
    79  - description: MapReduce omits default write concern
    80    operations:
    81      - name: mapReduce
    82        object: collection
    83        collectionOptions: {writeConcern: {}}
    84        arguments:
    85          map: { $code: 'function inc() { return emit(0, this.x + 1) }' }
    86          reduce: { $code: 'function sum(key, values) { return values.reduce((acc, x) => acc + x); }' }
    87          out: { inline: 1 }
    88    expectations:
    89      - command_started_event:
    90          command:
    91            mapReduce: *collection_name
    92            map: { $code: 'function inc() { return emit(0, this.x + 1) }' }
    93            reduce: { $code: 'function sum(key, values) { return values.reduce((acc, x) => acc + x); }' }
    94            out: { inline: 1 }
    95            writeConcern: null

View as plain text