...

Text file src/go.mongodb.org/mongo-driver/testdata/versioned-api/crud-api-version-1.yml

Documentation: go.mongodb.org/mongo-driver/testdata/versioned-api

     1description: "CRUD Api Version 1"
     2
     3schemaVersion: "1.4"
     4
     5runOnRequirements:
     6  - minServerVersion: "4.9"
     7
     8createEntities:
     9  - client:
    10      id: &client client
    11      observeEvents:
    12        - commandStartedEvent
    13      serverApi:
    14        version: "1"
    15        # Deprecation errors is set to true to ensure that drivers don't use any
    16        # deprecated server API in their logic.
    17        deprecationErrors: true
    18  - database:
    19      id: &database database
    20      client: *client
    21      databaseName: &databaseName versioned-api-tests
    22  - database:
    23      id: &adminDatabase adminDatabase
    24      client: *client
    25      databaseName: &adminDatabaseName admin
    26  - collection:
    27      id: &collection collection
    28      database: *database
    29      collectionName: &collectionName test
    30
    31_yamlAnchors:
    32  versions:
    33    - &expectedApiVersion
    34      apiVersion: "1"
    35      apiStrict: { $$unsetOrMatches: false }
    36      apiDeprecationErrors: true
    37
    38initialData:
    39  - collectionName: *collectionName
    40    databaseName: *databaseName
    41    documents:
    42      - { _id: 1, x: 11 }
    43      - { _id: 2, x: 22 }
    44      - { _id: 3, x: 33 }
    45      - { _id: 4, x: 44 }
    46      - { _id: 5, x: 55 }
    47
    48tests:
    49  - description: "aggregate on collection appends declared API version"
    50    operations:
    51      - name: aggregate
    52        object: *collection
    53        arguments:
    54          pipeline: &pipeline
    55            - $sort: { x : 1 }
    56            - $match: { _id: { $gt: 1 } }
    57    expectEvents:
    58      - client: *client
    59        events:
    60          - commandStartedEvent:
    61              command:
    62                aggregate: *collectionName
    63                pipeline: *pipeline
    64                <<: *expectedApiVersion
    65
    66  - description: "aggregate on database appends declared API version"
    67    runOnRequirements:
    68        # serverless does not support either of the current database-level aggregation stages ($listLocalSessions and
    69        # $currentOp)
    70      - serverless: forbid
    71    operations:
    72      - name: aggregate
    73        object: *adminDatabase
    74        arguments:
    75          pipeline: &pipeline
    76            - $listLocalSessions: {}
    77            - $limit: 1
    78    expectEvents:
    79      - client: *client
    80        events:
    81          - commandStartedEvent:
    82              command:
    83                aggregate: 1
    84                pipeline: *pipeline
    85                <<: *expectedApiVersion
    86
    87  - description: "bulkWrite appends declared API version"
    88    operations:
    89      - name: bulkWrite
    90        object: *collection
    91        arguments:
    92          requests:
    93            - insertOne:
    94                document: { _id: 6, x: 66 }
    95            - updateOne:
    96                filter: { _id: 2 }
    97                update: { $inc: { x: 1 } }
    98            - deleteMany:
    99                filter: { x: { $nin: [ 24, 34 ] } }
   100            - updateMany:
   101                filter: { _id: { $gt: 1 } }
   102                update: { $inc: { x: 1 } }
   103            - deleteOne:
   104                filter: { _id: 7 }
   105            - replaceOne:
   106                filter: { _id: 4 }
   107                replacement: { _id: 4, x: 44 }
   108                upsert: true
   109          ordered: true
   110    expectEvents:
   111      - client: *client
   112        events:
   113          - commandStartedEvent:
   114              command:
   115                insert: *collectionName
   116                documents:
   117                  - { _id: 6, x: 66 }
   118                <<: *expectedApiVersion
   119          - commandStartedEvent:
   120              command:
   121                update: *collectionName
   122                updates:
   123                  - q: { _id: 2 }
   124                    u: { $inc: { x: 1 } }
   125                    multi: { $$unsetOrMatches: false }
   126                    upsert: { $$unsetOrMatches: false }
   127                <<: *expectedApiVersion
   128          - commandStartedEvent:
   129              command:
   130                delete: *collectionName
   131                deletes:
   132                  - { q: { x: { $nin: [ 24, 34 ] } }, limit: 0 }
   133                <<: *expectedApiVersion
   134          - commandStartedEvent:
   135              command:
   136                update: *collectionName
   137                updates:
   138                  - q: { _id: { $gt: 1 } }
   139                    u: { $inc: { x: 1 } }
   140                    multi: true
   141                    upsert: { $$unsetOrMatches: false }
   142                <<: *expectedApiVersion
   143          - commandStartedEvent:
   144              command:
   145                delete: *collectionName
   146                deletes:
   147                  - { q: { _id: 7 }, limit: 1 }
   148                <<: *expectedApiVersion
   149          - commandStartedEvent:
   150              command:
   151                update: *collectionName
   152                updates:
   153                  - q: { _id: 4 }
   154                    u: { _id: 4, x: 44 }
   155                    multi: { $$unsetOrMatches: false }
   156                    upsert: true
   157                <<: *expectedApiVersion
   158
   159  - description: "countDocuments appends declared API version"
   160    operations:
   161      - name: countDocuments
   162        object: *collection
   163        arguments:
   164          filter: &filter
   165            x : { $gt: 11 }
   166    expectEvents:
   167      - client: *client
   168        events:
   169          - commandStartedEvent:
   170              command:
   171                aggregate: *collectionName
   172                pipeline:
   173                  - { $match: *filter }
   174                  - { $group: { _id: 1, n: { $sum: 1 } } }
   175                <<: *expectedApiVersion
   176
   177  - description: "deleteMany appends declared API version"
   178    operations:
   179      - name: deleteMany
   180        object: *collection
   181        arguments:
   182          filter: { x: { $nin: [ 24, 34 ] } }
   183    expectEvents:
   184      - client: *client
   185        events:
   186          - commandStartedEvent:
   187              command:
   188                delete: *collectionName
   189                deletes:
   190                  - { q: { x: { $nin: [ 24, 34 ] } }, limit: 0 }
   191                <<: *expectedApiVersion
   192
   193  - description: "deleteOne appends declared API version"
   194    operations:
   195      - name: deleteOne
   196        object: *collection
   197        arguments:
   198          filter: { _id: 7 }
   199    expectEvents:
   200      - client: *client
   201        events:
   202          - commandStartedEvent:
   203              command:
   204                delete: *collectionName
   205                deletes:
   206                  - { q: { _id: 7 }, limit: 1 }
   207                <<: *expectedApiVersion
   208
   209  - description: "distinct appends declared API version"
   210    operations:
   211      - name: distinct
   212        object: *collection
   213        arguments:
   214          fieldName: x
   215          filter: {}
   216    expectEvents:
   217      - client: *client
   218        events:
   219          - commandStartedEvent:
   220              command:
   221                distinct: *collectionName
   222                key: x
   223                <<: *expectedApiVersion
   224
   225  - description: "estimatedDocumentCount appends declared API version"
   226    # See: https://jira.mongodb.org/browse/SERVER-63850
   227    runOnRequirements:
   228      - minServerVersion: "5.0.9"
   229        maxServerVersion: "5.0.99"
   230      - minServerVersion: "5.3.2"
   231    operations:
   232      - name: estimatedDocumentCount
   233        object: *collection
   234        arguments: {}
   235    expectEvents:
   236      - client: *client
   237        events:
   238          - commandStartedEvent:
   239              command:
   240                count: *collectionName
   241                <<: *expectedApiVersion
   242
   243  - description: "find and getMore append API version"
   244    operations:
   245      - name: find
   246        object: *collection
   247        arguments:
   248          filter: {}
   249          sort: { _id: 1 }
   250          batchSize: 3
   251        expectResult:
   252          - { _id: 1, x: 11 }
   253          - { _id: 2, x: 22 }
   254          - { _id: 3, x: 33 }
   255          - { _id: 4, x: 44 }
   256          - { _id: 5, x: 55 }
   257    expectEvents:
   258      - client: *client
   259        events:
   260          - commandStartedEvent:
   261              command:
   262                find: *collectionName
   263                <<: *expectedApiVersion
   264          - commandStartedEvent:
   265              command:
   266                getMore: { $$type: [ int, long ] }
   267                <<: *expectedApiVersion
   268
   269  - description: "findOneAndDelete appends declared API version"
   270    operations:
   271      - name: findOneAndDelete
   272        object: *collection
   273        arguments:
   274          filter: &filter { _id: 1 }
   275    expectEvents:
   276      - client: *client
   277        events:
   278          - commandStartedEvent:
   279              command:
   280                findAndModify: *collectionName
   281                query: *filter
   282                remove: true
   283                <<: *expectedApiVersion
   284
   285  - description: "findOneAndReplace appends declared API version"
   286    operations:
   287      - name: findOneAndReplace
   288        object: *collection
   289        arguments:
   290          filter: &filter { _id: 1 }
   291          replacement: &replacement { x: 33 }
   292    expectEvents:
   293      - client: *client
   294        events:
   295          - commandStartedEvent:
   296              command:
   297                findAndModify: *collectionName
   298                query: *filter
   299                update: *replacement
   300                <<: *expectedApiVersion
   301
   302  - description: "findOneAndUpdate appends declared API version"
   303    operations:
   304      - name: findOneAndUpdate
   305        object: collection
   306        arguments:
   307          filter: &filter { _id: 1 }
   308          update: &update { $inc: { x: 1 } }
   309    expectEvents:
   310      - client: *client
   311        events:
   312          - commandStartedEvent:
   313              command:
   314                findAndModify: *collectionName
   315                query: *filter
   316                update: *update
   317                <<: *expectedApiVersion
   318
   319  - description: "insertMany appends declared API version"
   320    operations:
   321      - name: insertMany
   322        object: *collection
   323        arguments:
   324          documents:
   325            - { _id: 6, x: 66 }
   326            - { _id: 7, x: 77 }
   327    expectEvents:
   328      - client: *client
   329        events:
   330          - commandStartedEvent:
   331              command:
   332                insert: *collectionName
   333                documents:
   334                  - { _id: 6, x: 66 }
   335                  - { _id: 7, x: 77 }
   336                <<: *expectedApiVersion
   337
   338  - description: "insertOne appends declared API version"
   339    operations:
   340      - name: insertOne
   341        object: *collection
   342        arguments:
   343          document: { _id: 6, x: 66 }
   344    expectEvents:
   345      - client: *client
   346        events:
   347          - commandStartedEvent:
   348              command:
   349                insert: *collectionName
   350                documents:
   351                  - { _id: 6, x: 66 }
   352                <<: *expectedApiVersion
   353
   354  - description: "replaceOne appends declared API version"
   355    operations:
   356      - name: replaceOne
   357        object: *collection
   358        arguments:
   359          filter: { _id: 4 }
   360          replacement: { _id: 4, x: 44 }
   361          upsert: true
   362    expectEvents:
   363      - client: *client
   364        events:
   365          - commandStartedEvent:
   366              command:
   367                update: *collectionName
   368                updates:
   369                  - q: { _id: 4 }
   370                    u: { _id: 4, x: 44 }
   371                    multi: { $$unsetOrMatches: false }
   372                    upsert: true
   373                <<: *expectedApiVersion
   374
   375  - description: "updateMany appends declared API version"
   376    operations:
   377      - name: updateMany
   378        object: *collection
   379        arguments:
   380          filter: { _id: { $gt: 1 } }
   381          update: { $inc: { x: 1 } }
   382    expectEvents:
   383      - client: *client
   384        events:
   385          - commandStartedEvent:
   386              command:
   387                update: *collectionName
   388                updates:
   389                  - q: { _id: { $gt: 1 } }
   390                    u: { $inc: { x: 1 } }
   391                    multi: true
   392                    upsert: { $$unsetOrMatches: false }
   393                <<: *expectedApiVersion
   394
   395  - description: "updateOne appends declared API version"
   396    operations:
   397      - name: updateOne
   398        object: *collection
   399        arguments:
   400          filter: { _id: 2 }
   401          update: { $inc: { x: 1 } }
   402    expectEvents:
   403      - client: *client
   404        events:
   405          - commandStartedEvent:
   406              command:
   407                update: *collectionName
   408                updates:
   409                  - q: { _id: 2 }
   410                    u: { $inc: { x: 1 } }
   411                    multi: { $$unsetOrMatches: false }
   412                    upsert: { $$unsetOrMatches: false }
   413                <<: *expectedApiVersion

View as plain text