...

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

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

     1description: "findOneAndReplace-dots_and_dollars"
     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      - &initialDocument { _id: 1 }
    23
    24tests:
    25  - description: "Replacing document with top-level dotted key on 3.6+ server"
    26    runOnRequirements:
    27      - minServerVersion: "3.6"
    28    operations:
    29      - name: findOneAndReplace
    30        object: *collection0
    31        arguments:
    32          filter: { _id: 1 }
    33          replacement: &dottedKey { _id: 1, a.b: 1 }
    34        expectResult: *initialDocument
    35    expectEvents: &expectEventsDottedKey
    36      - client: *client0
    37        events:
    38          - commandStartedEvent:
    39              command:
    40                findAndModify: *collection0Name
    41                query: { _id: 1 }
    42                update: *dottedKey
    43                new: { $$unsetOrMatches: false }
    44    outcome:
    45      - collectionName: *collection0Name
    46        databaseName: *database0Name
    47        documents:
    48          - *dottedKey
    49
    50  - description: "Replacing document with top-level dotted key on pre-3.6 server yields server-side error"
    51    runOnRequirements:
    52      - maxServerVersion: "3.4.99"
    53    operations:
    54      - name: findOneAndReplace
    55        object: *collection0
    56        arguments:
    57          filter: { _id: 1 }
    58          replacement: *dottedKey
    59        expectError:
    60          isClientError: false
    61    expectEvents: *expectEventsDottedKey
    62    outcome: *initialData
    63
    64  - description: "Replacing document with dollar-prefixed key in embedded doc on 5.0+ server"
    65    runOnRequirements:
    66      - minServerVersion: "5.0"
    67    operations:
    68      - name: findOneAndReplace
    69        object: *collection0
    70        arguments:
    71          filter: { _id: 1 }
    72          replacement: &dollarPrefixedKeyInEmbedded { _id: 1, a: { $b: 1 } }
    73        expectResult: *initialDocument
    74    expectEvents: &expectEventsDollarPrefixedKeyInEmbedded
    75      - client: *client0
    76        events:
    77          - commandStartedEvent:
    78              command:
    79                findAndModify: *collection0Name
    80                query: { _id: 1 }
    81                update: *dollarPrefixedKeyInEmbedded
    82                new: { $$unsetOrMatches: false }
    83    outcome:
    84      - collectionName: *collection0Name
    85        databaseName: *database0Name
    86        documents:
    87          - *dollarPrefixedKeyInEmbedded
    88
    89  - description: "Replacing document with dollar-prefixed key in embedded doc on pre-5.0 server yields server-side error"
    90    runOnRequirements:
    91      - maxServerVersion: "4.99"
    92    operations:
    93      - name: findOneAndReplace
    94        object: *collection0
    95        arguments:
    96          filter: { _id: 1 }
    97          replacement: *dollarPrefixedKeyInEmbedded
    98        expectError:
    99          isClientError: false
   100    expectEvents: *expectEventsDollarPrefixedKeyInEmbedded
   101    outcome: *initialData
   102
   103  - description: "Replacing document with dotted key in embedded doc on 3.6+ server"
   104    runOnRequirements:
   105      - minServerVersion: "3.6"
   106    operations:
   107      - name: findOneAndReplace
   108        object: *collection0
   109        arguments:
   110          filter: { _id: 1 }
   111          replacement: &dottedKeyInEmbedded { _id: 1, a: { b.c: 1 } }
   112        expectResult: *initialDocument
   113    expectEvents: &expectEventsDottedKeyInEmbedded
   114      - client: *client0
   115        events:
   116          - commandStartedEvent:
   117              command:
   118                findAndModify: *collection0Name
   119                query: { _id: 1 }
   120                update: *dottedKeyInEmbedded
   121                new: { $$unsetOrMatches: false }
   122    outcome:
   123      - collectionName: *collection0Name
   124        databaseName: *database0Name
   125        documents:
   126          - *dottedKeyInEmbedded
   127
   128  - description: "Replacing document with dotted key in embedded doc on pre-3.6 server yields server-side error"
   129    runOnRequirements:
   130      - maxServerVersion: "3.4.99"
   131    operations:
   132      - name: findOneAndReplace
   133        object: *collection0
   134        arguments:
   135          filter: { _id: 1 }
   136          replacement: *dottedKeyInEmbedded
   137        expectError:
   138          isClientError: false
   139    expectEvents: *expectEventsDottedKeyInEmbedded
   140    outcome: *initialData

View as plain text