...

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

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

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

View as plain text