...

Text file src/go.mongodb.org/mongo-driver/testdata/crud/unified/aggregate.json

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

     1{
     2  "description": "aggregate",
     3  "schemaVersion": "1.0",
     4  "createEntities": [
     5    {
     6      "client": {
     7        "id": "client0",
     8        "useMultipleMongoses": true,
     9        "observeEvents": [
    10          "commandStartedEvent"
    11        ]
    12      }
    13    },
    14    {
    15      "database": {
    16        "id": "database0",
    17        "client": "client0",
    18        "databaseName": "aggregate-tests"
    19      }
    20    },
    21    {
    22      "collection": {
    23        "id": "collection0",
    24        "database": "database0",
    25        "collectionName": "coll0"
    26      }
    27    }
    28  ],
    29  "initialData": [
    30    {
    31      "collectionName": "coll0",
    32      "databaseName": "aggregate-tests",
    33      "documents": [
    34        {
    35          "_id": 1,
    36          "x": 11
    37        },
    38        {
    39          "_id": 2,
    40          "x": 22
    41        },
    42        {
    43          "_id": 3,
    44          "x": 33
    45        },
    46        {
    47          "_id": 4,
    48          "x": 44
    49        },
    50        {
    51          "_id": 5,
    52          "x": 55
    53        },
    54        {
    55          "_id": 6,
    56          "x": 66
    57        }
    58      ]
    59    }
    60  ],
    61  "tests": [
    62    {
    63      "description": "aggregate with multiple batches works",
    64      "operations": [
    65        {
    66          "name": "aggregate",
    67          "arguments": {
    68            "pipeline": [
    69              {
    70                "$match": {
    71                  "_id": {
    72                    "$gt": 1
    73                  }
    74                }
    75              }
    76            ],
    77            "batchSize": 2
    78          },
    79          "object": "collection0",
    80          "expectResult": [
    81            {
    82              "_id": 2,
    83              "x": 22
    84            },
    85            {
    86              "_id": 3,
    87              "x": 33
    88            },
    89            {
    90              "_id": 4,
    91              "x": 44
    92            },
    93            {
    94              "_id": 5,
    95              "x": 55
    96            },
    97            {
    98              "_id": 6,
    99              "x": 66
   100            }
   101          ]
   102        }
   103      ],
   104      "expectEvents": [
   105        {
   106          "client": "client0",
   107          "events": [
   108            {
   109              "commandStartedEvent": {
   110                "command": {
   111                  "aggregate": "coll0",
   112                  "pipeline": [
   113                    {
   114                      "$match": {
   115                        "_id": {
   116                          "$gt": 1
   117                        }
   118                      }
   119                    }
   120                  ],
   121                  "cursor": {
   122                    "batchSize": 2
   123                  }
   124                },
   125                "commandName": "aggregate",
   126                "databaseName": "aggregate-tests"
   127              }
   128            },
   129            {
   130              "commandStartedEvent": {
   131                "command": {
   132                  "getMore": {
   133                    "$$type": [
   134                      "int",
   135                      "long"
   136                    ]
   137                  },
   138                  "collection": "coll0",
   139                  "batchSize": 2
   140                },
   141                "commandName": "getMore",
   142                "databaseName": "aggregate-tests"
   143              }
   144            },
   145            {
   146              "commandStartedEvent": {
   147                "command": {
   148                  "getMore": {
   149                    "$$type": [
   150                      "int",
   151                      "long"
   152                    ]
   153                  },
   154                  "collection": "coll0",
   155                  "batchSize": 2
   156                },
   157                "commandName": "getMore",
   158                "databaseName": "aggregate-tests"
   159              }
   160            }
   161          ]
   162        }
   163      ]
   164    },
   165    {
   166      "description": "aggregate with a string comment",
   167      "runOnRequirements": [
   168        {
   169          "minServerVersion": "3.6.0"
   170        }
   171      ],
   172      "operations": [
   173        {
   174          "name": "aggregate",
   175          "arguments": {
   176            "pipeline": [
   177              {
   178                "$match": {
   179                  "_id": {
   180                    "$gt": 1
   181                  }
   182                }
   183              }
   184            ],
   185            "comment": "comment"
   186          },
   187          "object": "collection0"
   188        }
   189      ],
   190      "expectEvents": [
   191        {
   192          "client": "client0",
   193          "events": [
   194            {
   195              "commandStartedEvent": {
   196                "command": {
   197                  "aggregate": "coll0",
   198                  "pipeline": [
   199                    {
   200                      "$match": {
   201                        "_id": {
   202                          "$gt": 1
   203                        }
   204                      }
   205                    }
   206                  ],
   207                  "comment": "comment"
   208                }
   209              }
   210            }
   211          ]
   212        }
   213      ]
   214    },
   215    {
   216      "description": "aggregate with a document comment",
   217      "runOnRequirements": [
   218        {
   219          "minServerVersion": "4.4"
   220        }
   221      ],
   222      "operations": [
   223        {
   224          "name": "aggregate",
   225          "arguments": {
   226            "pipeline": [
   227              {
   228                "$match": {
   229                  "_id": {
   230                    "$gt": 1
   231                  }
   232                }
   233              }
   234            ],
   235            "comment": {
   236              "content": "test"
   237            }
   238          },
   239          "object": "collection0"
   240        }
   241      ],
   242      "expectEvents": [
   243        {
   244          "client": "client0",
   245          "events": [
   246            {
   247              "commandStartedEvent": {
   248                "command": {
   249                  "aggregate": "coll0",
   250                  "pipeline": [
   251                    {
   252                      "$match": {
   253                        "_id": {
   254                          "$gt": 1
   255                        }
   256                      }
   257                    }
   258                  ],
   259                  "comment": {
   260                    "content": "test"
   261                  }
   262                }
   263              }
   264            }
   265          ]
   266        }
   267      ]
   268    },
   269    {
   270      "description": "aggregate with a document comment - pre 4.4",
   271      "skipReason": "TODO(GODRIVER-2386): aggregate only supports string comments",
   272      "runOnRequirements": [
   273        {
   274          "minServerVersion": "3.6.0",
   275          "maxServerVersion": "4.2.99"
   276        }
   277      ],
   278      "operations": [
   279        {
   280          "name": "aggregate",
   281          "object": "collection0",
   282          "arguments": {
   283            "pipeline": [
   284              {
   285                "$match": {
   286                  "_id": {
   287                    "$gt": 1
   288                  }
   289                }
   290              }
   291            ],
   292            "comment": {
   293              "content": "test"
   294            }
   295          },
   296          "expectError": {
   297            "isClientError": false
   298          }
   299        }
   300      ],
   301      "expectEvents": [
   302        {
   303          "client": "client0",
   304          "events": [
   305            {
   306              "commandStartedEvent": {
   307                "command": {
   308                  "aggregate": "coll0",
   309                  "pipeline": [
   310                    {
   311                      "$match": {
   312                        "_id": {
   313                          "$gt": 1
   314                        }
   315                      }
   316                    }
   317                  ],
   318                  "comment": {
   319                    "content": "test"
   320                  }
   321                },
   322                "commandName": "aggregate",
   323                "databaseName": "aggregate-tests"
   324              }
   325            }
   326          ]
   327        }
   328      ]
   329    },
   330    {
   331      "description": "aggregate with comment sets comment on getMore",
   332      "skipReason": "aggregate comments are string-only",
   333      "runOnRequirements": [
   334        {
   335          "minServerVersion": "4.4.0"
   336        }
   337      ],
   338      "operations": [
   339        {
   340          "name": "aggregate",
   341          "arguments": {
   342            "pipeline": [
   343              {
   344                "$match": {
   345                  "_id": {
   346                    "$gt": 1
   347                  }
   348                }
   349              }
   350            ],
   351            "batchSize": 2,
   352            "comment": {
   353              "content": "test"
   354            }
   355          },
   356          "object": "collection0",
   357          "expectResult": [
   358            {
   359              "_id": 2,
   360              "x": 22
   361            },
   362            {
   363              "_id": 3,
   364              "x": 33
   365            },
   366            {
   367              "_id": 4,
   368              "x": 44
   369            },
   370            {
   371              "_id": 5,
   372              "x": 55
   373            },
   374            {
   375              "_id": 6,
   376              "x": 66
   377            }
   378          ]
   379        }
   380      ],
   381      "expectEvents": [
   382        {
   383          "client": "client0",
   384          "events": [
   385            {
   386              "commandStartedEvent": {
   387                "command": {
   388                  "aggregate": "coll0",
   389                  "pipeline": [
   390                    {
   391                      "$match": {
   392                        "_id": {
   393                          "$gt": 1
   394                        }
   395                      }
   396                    }
   397                  ],
   398                  "cursor": {
   399                    "batchSize": 2
   400                  },
   401                  "comment": {
   402                    "content": "test"
   403                  }
   404                },
   405                "commandName": "aggregate",
   406                "databaseName": "aggregate-tests"
   407              }
   408            },
   409            {
   410              "commandStartedEvent": {
   411                "command": {
   412                  "getMore": {
   413                    "$$type": [
   414                      "int",
   415                      "long"
   416                    ]
   417                  },
   418                  "collection": "coll0",
   419                  "batchSize": 2,
   420                  "comment": {
   421                    "content": "test"
   422                  }
   423                },
   424                "commandName": "getMore",
   425                "databaseName": "aggregate-tests"
   426              }
   427            },
   428            {
   429              "commandStartedEvent": {
   430                "command": {
   431                  "getMore": {
   432                    "$$type": [
   433                      "int",
   434                      "long"
   435                    ]
   436                  },
   437                  "collection": "coll0",
   438                  "batchSize": 2,
   439                  "comment": {
   440                    "content": "test"
   441                  }
   442                },
   443                "commandName": "getMore",
   444                "databaseName": "aggregate-tests"
   445              }
   446            }
   447          ]
   448        }
   449      ]
   450    },
   451    {
   452      "description": "aggregate with comment does not set comment on getMore - pre 4.4",
   453      "runOnRequirements": [
   454        {
   455          "minServerVersion": "3.6.0",
   456          "maxServerVersion": "4.3.99"
   457        }
   458      ],
   459      "operations": [
   460        {
   461          "name": "aggregate",
   462          "arguments": {
   463            "pipeline": [
   464              {
   465                "$match": {
   466                  "_id": {
   467                    "$gt": 1
   468                  }
   469                }
   470              }
   471            ],
   472            "batchSize": 2,
   473            "comment": "comment"
   474          },
   475          "object": "collection0",
   476          "expectResult": [
   477            {
   478              "_id": 2,
   479              "x": 22
   480            },
   481            {
   482              "_id": 3,
   483              "x": 33
   484            },
   485            {
   486              "_id": 4,
   487              "x": 44
   488            },
   489            {
   490              "_id": 5,
   491              "x": 55
   492            },
   493            {
   494              "_id": 6,
   495              "x": 66
   496            }
   497          ]
   498        }
   499      ],
   500      "expectEvents": [
   501        {
   502          "client": "client0",
   503          "events": [
   504            {
   505              "commandStartedEvent": {
   506                "command": {
   507                  "aggregate": "coll0",
   508                  "pipeline": [
   509                    {
   510                      "$match": {
   511                        "_id": {
   512                          "$gt": 1
   513                        }
   514                      }
   515                    }
   516                  ],
   517                  "cursor": {
   518                    "batchSize": 2
   519                  },
   520                  "comment": "comment"
   521                },
   522                "commandName": "aggregate",
   523                "databaseName": "aggregate-tests"
   524              }
   525            },
   526            {
   527              "commandStartedEvent": {
   528                "command": {
   529                  "getMore": {
   530                    "$$type": [
   531                      "int",
   532                      "long"
   533                    ]
   534                  },
   535                  "collection": "coll0",
   536                  "batchSize": 2,
   537                  "comment": {
   538                    "$$exists": false
   539                  }
   540                },
   541                "commandName": "getMore",
   542                "databaseName": "aggregate-tests"
   543              }
   544            },
   545            {
   546              "commandStartedEvent": {
   547                "command": {
   548                  "getMore": {
   549                    "$$type": [
   550                      "int",
   551                      "long"
   552                    ]
   553                  },
   554                  "collection": "coll0",
   555                  "batchSize": 2,
   556                  "comment": {
   557                    "$$exists": false
   558                  }
   559                },
   560                "commandName": "getMore",
   561                "databaseName": "aggregate-tests"
   562              }
   563            }
   564          ]
   565        }
   566      ]
   567    }
   568  ]
   569}

View as plain text