...

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

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

     1description: "insertMany-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
    23tests:
    24  - description: "Inserting document with top-level dollar-prefixed key on 5.0+ server"
    25    runOnRequirements:
    26      - minServerVersion: "5.0"
    27    operations:
    28      - name: insertMany
    29        object: *collection0
    30        arguments:
    31          documents:
    32            - &dollarPrefixedKey { _id: 1, $a: 1 }
    33        expectResult: &insertResult
    34          # InsertManyResult is optional because all of its fields are optional
    35          $$unsetOrMatches: { insertedIds: { $$unsetOrMatches: { 0: 1 } } }
    36    expectEvents: &expectEventsDollarPrefixedKey
    37      - client: *client0
    38        events:
    39          - commandStartedEvent:
    40              command:
    41                insert: *collection0Name
    42                documents:
    43                  - *dollarPrefixedKey
    44    outcome:
    45      - collectionName: *collection0Name
    46        databaseName: *database0Name
    47        documents:
    48          - *dollarPrefixedKey
    49
    50  - description: "Inserting document with top-level dollar-prefixed key on pre-5.0 server yields server-side error"
    51    runOnRequirements:
    52      - maxServerVersion: "4.99"
    53    operations:
    54      - name: insertMany
    55        object: *collection0
    56        arguments:
    57          documents:
    58            - *dollarPrefixedKey
    59        expectError:
    60          isClientError: false
    61    expectEvents: *expectEventsDollarPrefixedKey
    62    outcome: *initialData
    63
    64  - description: "Inserting document with top-level dotted key"
    65    operations:
    66      - name: insertMany
    67        object: *collection0
    68        arguments:
    69          documents:
    70            - &dottedKey { _id: 1, a.b: 1 }
    71        expectResult: *insertResult
    72    expectEvents:
    73      - client: *client0
    74        events:
    75          - commandStartedEvent:
    76              command:
    77                insert: *collection0Name
    78                documents:
    79                  - *dottedKey
    80    outcome:
    81      - collectionName: *collection0Name
    82        databaseName: *database0Name
    83        documents:
    84          - *dottedKey
    85
    86  - description: "Inserting document with dollar-prefixed key in embedded doc"
    87    operations:
    88      - name: insertMany
    89        object: *collection0
    90        arguments:
    91          documents:
    92            - &dollarPrefixedKeyInEmbedded { _id: 1, a: { $b: 1 } }
    93        expectResult: *insertResult
    94    expectEvents:
    95      - client: *client0
    96        events:
    97          - commandStartedEvent:
    98              command:
    99                insert: *collection0Name
   100                documents:
   101                  - *dollarPrefixedKeyInEmbedded
   102    outcome:
   103      - collectionName: *collection0Name
   104        databaseName: *database0Name
   105        documents:
   106          - *dollarPrefixedKeyInEmbedded
   107
   108  - description: "Inserting document with dotted key in embedded doc"
   109    operations:
   110      - name: insertMany
   111        object: *collection0
   112        arguments:
   113          documents:
   114            - &dottedKeyInEmbedded { _id: 1, a: { b.c: 1 } }
   115        expectResult: *insertResult
   116    expectEvents:
   117      - client: *client0
   118        events:
   119          - commandStartedEvent:
   120              command:
   121                insert: *collection0Name
   122                documents:
   123                  - *dottedKeyInEmbedded
   124    outcome:
   125      - collectionName: *collection0Name
   126        databaseName: *database0Name
   127        documents:
   128          - *dottedKeyInEmbedded

View as plain text