...

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

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

     1description: "updateOne-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: "UpdateOne with let option"
    27    runOnRequirements:
    28      - minServerVersion: "5.0"
    29    operations:
    30      - name: updateOne
    31        object: *collection0
    32        arguments:
    33          filter: &filter
    34            $expr:
    35              $eq: [ "$_id", "$$id" ]
    36          update: &update
    37            - $set: {x: "$$x" }
    38          let: &let0
    39            id: 1
    40            x: "foo"
    41        expectResult:
    42          matchedCount: 1
    43          modifiedCount: 1
    44          upsertedCount: 0
    45    expectEvents:
    46      - client: *client0
    47        events:
    48          - commandStartedEvent:
    49              command:
    50                update: *collection0Name
    51                updates:
    52                  -
    53                    q: *filter
    54                    u: *update
    55                    multi: { $$unsetOrMatches: false }
    56                    upsert: { $$unsetOrMatches: false }
    57                let: *let0
    58    outcome:
    59      -
    60        collectionName: *collection0Name
    61        databaseName: *database0Name
    62        documents:
    63          - { _id: 1, x: "foo" }
    64          - { _id: 2 }
    65
    66  - description: "UpdateOne with let option unsupported (server-side error)"
    67    runOnRequirements:
    68      - minServerVersion: "4.2.0"
    69        maxServerVersion: "4.4.99"
    70    operations:
    71      - name: updateOne
    72        object: *collection0
    73        arguments:
    74          filter: &filter1
    75            _id: 1
    76          update: &update1
    77            - $set: {x: "$$x"}
    78          let: &let1
    79            x: foo
    80        expectError:
    81          errorContains: "'update.let' is an unknown field"
    82          isClientError: false
    83    expectEvents:
    84      - client: *client0
    85        events:
    86          - commandStartedEvent:
    87              command:
    88                update: *collection0Name
    89                updates:
    90                  -
    91                    q: *filter1
    92                    u: *update1
    93                    multi: { $$unsetOrMatches: false }
    94                    upsert: { $$unsetOrMatches: false }
    95                let: *let1
    96    outcome:
    97      -
    98        collectionName: *collection0Name
    99        databaseName: *database0Name
   100        documents:
   101          - { _id: 1 }
   102          - { _id: 2 }

View as plain text