...

Text file src/go.mongodb.org/mongo-driver/testdata/crud/unified/findOneAndReplace-let.yml

Documentation: go.mongodb.org/mongo-driver/testdata/crud/unified

     1description: "findOneAndReplace-let"
     2
     3schemaVersion: "1.0"
     4
     5createEntities:
     6  - client:
     7      id: &client0 client0
     8      observeEvents: [ commandStartedEvent ]
     9  - database:
    10      id: &database0 database0
    11      client: *client0
    12      databaseName: &database0Name crud-tests
    13  - collection:
    14      id: &collection0 collection0
    15      database: *database0
    16      collectionName: &collection0Name coll0
    17
    18initialData: &initialData
    19  - collectionName: *collection0Name
    20    databaseName: *database0Name
    21    documents:
    22      - { _id: 1 }
    23      - { _id: 2 }
    24
    25tests:
    26  - description: "findOneAndReplace with let option"
    27    runOnRequirements:
    28      - minServerVersion: "5.0"
    29    operations:
    30      - name: findOneAndReplace
    31        object: *collection0
    32        arguments:
    33          filter: &filter
    34            $expr:
    35              $eq: [ "$_id", "$$id" ]
    36          replacement: &replacement
    37            x: "x"
    38          let: &let0
    39            id: 1
    40        expectResult:
    41          _id: 1
    42    expectEvents:
    43      - client: *client0
    44        events:
    45          - commandStartedEvent:
    46              command:
    47                findAndModify: *collection0Name
    48                query: *filter
    49                update: *replacement
    50                let: *let0
    51    outcome:
    52      -
    53        collectionName: *collection0Name
    54        databaseName: *database0Name
    55        documents:
    56          - { _id: 1, x: "x" }
    57          - { _id: 2 }
    58
    59  - description: "findOneAndReplace with let option unsupported (server-side error)"
    60    runOnRequirements:
    61      - minServerVersion: "4.2.0"
    62        maxServerVersion: "4.4.99"
    63    operations:
    64      - name: findOneAndReplace
    65        object: *collection0
    66        arguments:
    67          filter: &filter1
    68            $expr:
    69              $eq: [ "$_id", "$$id" ]
    70          replacement: &replacement1
    71            x: "x"
    72          let: &let1
    73            id: 1
    74        expectError:
    75          # This error message is consistent between 4.2.x and 4.4.x servers.
    76          # Older servers return a different error message.
    77          errorContains: "field 'let' is an unknown field"
    78          isClientError: false
    79    expectEvents:
    80      - client: *client0
    81        events:
    82          - commandStartedEvent:
    83              command:
    84                findAndModify: *collection0Name
    85                query: *filter1
    86                update: *replacement1
    87                let: *let1
    88    outcome:
    89      -
    90        collectionName: *collection0Name
    91        databaseName: *database0Name
    92        documents:
    93          - { _id: 1 }
    94          - { _id: 2 }

View as plain text