...

Text file src/go.mongodb.org/mongo-driver/testdata/unified-test-format/valid-pass/poc-crud.json

Documentation: go.mongodb.org/mongo-driver/testdata/unified-test-format/valid-pass

     1{
     2  "description": "poc-crud",
     3  "schemaVersion": "1.4",
     4  "createEntities": [
     5    {
     6      "client": {
     7        "id": "client0",
     8        "observeEvents": [
     9          "commandStartedEvent"
    10        ]
    11      }
    12    },
    13    {
    14      "database": {
    15        "id": "database0",
    16        "client": "client0",
    17        "databaseName": "crud-tests"
    18      }
    19    },
    20    {
    21      "database": {
    22        "id": "database1",
    23        "client": "client0",
    24        "databaseName": "admin"
    25      }
    26    },
    27    {
    28      "collection": {
    29        "id": "collection0",
    30        "database": "database0",
    31        "collectionName": "coll0"
    32      }
    33    },
    34    {
    35      "collection": {
    36        "id": "collection1",
    37        "database": "database0",
    38        "collectionName": "coll1"
    39      }
    40    },
    41    {
    42      "collection": {
    43        "id": "collection2",
    44        "database": "database0",
    45        "collectionName": "coll2",
    46        "collectionOptions": {
    47          "readConcern": {
    48            "level": "majority"
    49          }
    50        }
    51      }
    52    }
    53  ],
    54  "initialData": [
    55    {
    56      "collectionName": "coll0",
    57      "databaseName": "crud-tests",
    58      "documents": [
    59        {
    60          "_id": 1,
    61          "x": 11
    62        },
    63        {
    64          "_id": 2,
    65          "x": 22
    66        }
    67      ]
    68    },
    69    {
    70      "collectionName": "coll1",
    71      "databaseName": "crud-tests",
    72      "documents": [
    73        {
    74          "_id": 1,
    75          "x": 11
    76        }
    77      ]
    78    },
    79    {
    80      "collectionName": "coll2",
    81      "databaseName": "crud-tests",
    82      "documents": [
    83        {
    84          "_id": 1,
    85          "x": 11
    86        },
    87        {
    88          "_id": 2,
    89          "x": 22
    90        },
    91        {
    92          "_id": 3,
    93          "x": 33
    94        }
    95      ]
    96    },
    97    {
    98      "collectionName": "aggregate_out",
    99      "databaseName": "crud-tests",
   100      "documents": []
   101    }
   102  ],
   103  "tests": [
   104    {
   105      "description": "BulkWrite with mixed ordered operations",
   106      "operations": [
   107        {
   108          "name": "bulkWrite",
   109          "object": "collection0",
   110          "arguments": {
   111            "requests": [
   112              {
   113                "insertOne": {
   114                  "document": {
   115                    "_id": 3,
   116                    "x": 33
   117                  }
   118                }
   119              },
   120              {
   121                "updateOne": {
   122                  "filter": {
   123                    "_id": 2
   124                  },
   125                  "update": {
   126                    "$inc": {
   127                      "x": 1
   128                    }
   129                  }
   130                }
   131              },
   132              {
   133                "updateMany": {
   134                  "filter": {
   135                    "_id": {
   136                      "$gt": 1
   137                    }
   138                  },
   139                  "update": {
   140                    "$inc": {
   141                      "x": 1
   142                    }
   143                  }
   144                }
   145              },
   146              {
   147                "insertOne": {
   148                  "document": {
   149                    "_id": 4,
   150                    "x": 44
   151                  }
   152                }
   153              },
   154              {
   155                "deleteMany": {
   156                  "filter": {
   157                    "x": {
   158                      "$nin": [
   159                        24,
   160                        34
   161                      ]
   162                    }
   163                  }
   164                }
   165              },
   166              {
   167                "replaceOne": {
   168                  "filter": {
   169                    "_id": 4
   170                  },
   171                  "replacement": {
   172                    "_id": 4,
   173                    "x": 44
   174                  },
   175                  "upsert": true
   176                }
   177              }
   178            ],
   179            "ordered": true
   180          },
   181          "expectResult": {
   182            "deletedCount": 2,
   183            "insertedCount": 2,
   184            "insertedIds": {
   185              "$$unsetOrMatches": {
   186                "0": 3,
   187                "3": 4
   188              }
   189            },
   190            "matchedCount": 3,
   191            "modifiedCount": 3,
   192            "upsertedCount": 1,
   193            "upsertedIds": {
   194              "5": 4
   195            }
   196          }
   197        }
   198      ],
   199      "outcome": [
   200        {
   201          "collectionName": "coll0",
   202          "databaseName": "crud-tests",
   203          "documents": [
   204            {
   205              "_id": 2,
   206              "x": 24
   207            },
   208            {
   209              "_id": 3,
   210              "x": 34
   211            },
   212            {
   213              "_id": 4,
   214              "x": 44
   215            }
   216          ]
   217        }
   218      ]
   219    },
   220    {
   221      "description": "InsertMany continue-on-error behavior with unordered (duplicate key in requests)",
   222      "operations": [
   223        {
   224          "name": "insertMany",
   225          "object": "collection1",
   226          "arguments": {
   227            "documents": [
   228              {
   229                "_id": 2,
   230                "x": 22
   231              },
   232              {
   233                "_id": 2,
   234                "x": 22
   235              },
   236              {
   237                "_id": 3,
   238                "x": 33
   239              }
   240            ],
   241            "ordered": false
   242          },
   243          "expectError": {
   244            "expectResult": {
   245              "$$unsetOrMatches": {
   246                "deletedCount": 0,
   247                "insertedCount": 2,
   248                "matchedCount": 0,
   249                "modifiedCount": 0,
   250                "upsertedCount": 0,
   251                "upsertedIds": {}
   252              }
   253            }
   254          }
   255        }
   256      ],
   257      "outcome": [
   258        {
   259          "collectionName": "coll1",
   260          "databaseName": "crud-tests",
   261          "documents": [
   262            {
   263              "_id": 1,
   264              "x": 11
   265            },
   266            {
   267              "_id": 2,
   268              "x": 22
   269            },
   270            {
   271              "_id": 3,
   272              "x": 33
   273            }
   274          ]
   275        }
   276      ]
   277    },
   278    {
   279      "description": "ReplaceOne prohibits atomic modifiers",
   280      "operations": [
   281        {
   282          "name": "replaceOne",
   283          "object": "collection1",
   284          "arguments": {
   285            "filter": {
   286              "_id": 1
   287            },
   288            "replacement": {
   289              "$set": {
   290                "x": 22
   291              }
   292            }
   293          },
   294          "expectError": {
   295            "isClientError": true
   296          }
   297        }
   298      ],
   299      "expectEvents": [
   300        {
   301          "client": "client0",
   302          "events": []
   303        }
   304      ],
   305      "outcome": [
   306        {
   307          "collectionName": "coll1",
   308          "databaseName": "crud-tests",
   309          "documents": [
   310            {
   311              "_id": 1,
   312              "x": 11
   313            }
   314          ]
   315        }
   316      ]
   317    },
   318    {
   319      "description": "readConcern majority with out stage",
   320      "runOnRequirements": [
   321        {
   322          "minServerVersion": "4.1.0",
   323          "topologies": [
   324            "replicaset",
   325            "sharded-replicaset"
   326          ],
   327          "serverless": "forbid"
   328        }
   329      ],
   330      "operations": [
   331        {
   332          "name": "aggregate",
   333          "object": "collection2",
   334          "arguments": {
   335            "pipeline": [
   336              {
   337                "$sort": {
   338                  "x": 1
   339                }
   340              },
   341              {
   342                "$match": {
   343                  "_id": {
   344                    "$gt": 1
   345                  }
   346                }
   347              },
   348              {
   349                "$out": "aggregate_out"
   350              }
   351            ]
   352          }
   353        }
   354      ],
   355      "expectEvents": [
   356        {
   357          "client": "client0",
   358          "events": [
   359            {
   360              "commandStartedEvent": {
   361                "command": {
   362                  "aggregate": "coll2",
   363                  "pipeline": [
   364                    {
   365                      "$sort": {
   366                        "x": 1
   367                      }
   368                    },
   369                    {
   370                      "$match": {
   371                        "_id": {
   372                          "$gt": 1
   373                        }
   374                      }
   375                    },
   376                    {
   377                      "$out": "aggregate_out"
   378                    }
   379                  ],
   380                  "readConcern": {
   381                    "level": "majority"
   382                  }
   383                },
   384                "commandName": "aggregate",
   385                "databaseName": "crud-tests"
   386              }
   387            }
   388          ]
   389        }
   390      ],
   391      "outcome": [
   392        {
   393          "collectionName": "aggregate_out",
   394          "databaseName": "crud-tests",
   395          "documents": [
   396            {
   397              "_id": 2,
   398              "x": 22
   399            },
   400            {
   401              "_id": 3,
   402              "x": 33
   403            }
   404          ]
   405        }
   406      ]
   407    },
   408    {
   409      "description": "Aggregate with $listLocalSessions",
   410      "runOnRequirements": [
   411        {
   412          "minServerVersion": "3.6.0",
   413          "serverless": "forbid"
   414        }
   415      ],
   416      "operations": [
   417        {
   418          "name": "aggregate",
   419          "object": "database1",
   420          "arguments": {
   421            "pipeline": [
   422              {
   423                "$listLocalSessions": {}
   424              },
   425              {
   426                "$limit": 1
   427              },
   428              {
   429                "$addFields": {
   430                  "dummy": "dummy field"
   431                }
   432              },
   433              {
   434                "$project": {
   435                  "_id": 0,
   436                  "dummy": 1
   437                }
   438              }
   439            ]
   440          },
   441          "expectResult": [
   442            {
   443              "dummy": "dummy field"
   444            }
   445          ]
   446        }
   447      ]
   448    }
   449  ]
   450}

View as plain text