...

Text file src/go.mongodb.org/mongo-driver/testdata/convenient-transactions/callback-commits.json

Documentation: go.mongodb.org/mongo-driver/testdata/convenient-transactions

     1{
     2  "runOn": [
     3    {
     4      "minServerVersion": "4.0",
     5      "topology": [
     6        "replicaset"
     7      ]
     8    },
     9    {
    10      "minServerVersion": "4.1.8",
    11      "topology": [
    12        "sharded"
    13      ]
    14    }
    15  ],
    16  "database_name": "withTransaction-tests",
    17  "collection_name": "test",
    18  "data": [],
    19  "tests": [
    20    {
    21      "description": "withTransaction succeeds if callback commits",
    22      "useMultipleMongoses": true,
    23      "operations": [
    24        {
    25          "name": "withTransaction",
    26          "object": "session0",
    27          "arguments": {
    28            "callback": {
    29              "operations": [
    30                {
    31                  "name": "insertOne",
    32                  "object": "collection",
    33                  "arguments": {
    34                    "session": "session0",
    35                    "document": {
    36                      "_id": 1
    37                    }
    38                  },
    39                  "result": {
    40                    "insertedId": 1
    41                  }
    42                },
    43                {
    44                  "name": "insertOne",
    45                  "object": "collection",
    46                  "arguments": {
    47                    "session": "session0",
    48                    "document": {
    49                      "_id": 2
    50                    }
    51                  },
    52                  "result": {
    53                    "insertedId": 2
    54                  }
    55                },
    56                {
    57                  "name": "commitTransaction",
    58                  "object": "session0"
    59                }
    60              ]
    61            }
    62          }
    63        }
    64      ],
    65      "expectations": [
    66        {
    67          "command_started_event": {
    68            "command": {
    69              "insert": "test",
    70              "documents": [
    71                {
    72                  "_id": 1
    73                }
    74              ],
    75              "ordered": true,
    76              "lsid": "session0",
    77              "txnNumber": {
    78                "$numberLong": "1"
    79              },
    80              "startTransaction": true,
    81              "autocommit": false,
    82              "readConcern": null,
    83              "writeConcern": null
    84            },
    85            "command_name": "insert",
    86            "database_name": "withTransaction-tests"
    87          }
    88        },
    89        {
    90          "command_started_event": {
    91            "command": {
    92              "insert": "test",
    93              "documents": [
    94                {
    95                  "_id": 2
    96                }
    97              ],
    98              "ordered": true,
    99              "lsid": "session0",
   100              "txnNumber": {
   101                "$numberLong": "1"
   102              },
   103              "autocommit": false,
   104              "readConcern": null,
   105              "startTransaction": null,
   106              "writeConcern": null
   107            },
   108            "command_name": "insert",
   109            "database_name": "withTransaction-tests"
   110          }
   111        },
   112        {
   113          "command_started_event": {
   114            "command": {
   115              "commitTransaction": 1,
   116              "lsid": "session0",
   117              "txnNumber": {
   118                "$numberLong": "1"
   119              },
   120              "autocommit": false,
   121              "readConcern": null,
   122              "startTransaction": null,
   123              "writeConcern": null
   124            },
   125            "command_name": "commitTransaction",
   126            "database_name": "admin"
   127          }
   128        }
   129      ],
   130      "outcome": {
   131        "collection": {
   132          "data": [
   133            {
   134              "_id": 1
   135            },
   136            {
   137              "_id": 2
   138            }
   139          ]
   140        }
   141      }
   142    },
   143    {
   144      "description": "withTransaction still succeeds if callback commits and runs extra op",
   145      "useMultipleMongoses": true,
   146      "operations": [
   147        {
   148          "name": "withTransaction",
   149          "object": "session0",
   150          "arguments": {
   151            "callback": {
   152              "operations": [
   153                {
   154                  "name": "insertOne",
   155                  "object": "collection",
   156                  "arguments": {
   157                    "session": "session0",
   158                    "document": {
   159                      "_id": 1
   160                    }
   161                  },
   162                  "result": {
   163                    "insertedId": 1
   164                  }
   165                },
   166                {
   167                  "name": "insertOne",
   168                  "object": "collection",
   169                  "arguments": {
   170                    "session": "session0",
   171                    "document": {
   172                      "_id": 2
   173                    }
   174                  },
   175                  "result": {
   176                    "insertedId": 2
   177                  }
   178                },
   179                {
   180                  "name": "commitTransaction",
   181                  "object": "session0"
   182                },
   183                {
   184                  "name": "insertOne",
   185                  "object": "collection",
   186                  "arguments": {
   187                    "session": "session0",
   188                    "document": {
   189                      "_id": 3
   190                    }
   191                  },
   192                  "result": {
   193                    "insertedId": 3
   194                  }
   195                }
   196              ]
   197            }
   198          }
   199        }
   200      ],
   201      "expectations": [
   202        {
   203          "command_started_event": {
   204            "command": {
   205              "insert": "test",
   206              "documents": [
   207                {
   208                  "_id": 1
   209                }
   210              ],
   211              "ordered": true,
   212              "lsid": "session0",
   213              "txnNumber": {
   214                "$numberLong": "1"
   215              },
   216              "startTransaction": true,
   217              "autocommit": false,
   218              "readConcern": null,
   219              "writeConcern": null
   220            },
   221            "command_name": "insert",
   222            "database_name": "withTransaction-tests"
   223          }
   224        },
   225        {
   226          "command_started_event": {
   227            "command": {
   228              "insert": "test",
   229              "documents": [
   230                {
   231                  "_id": 2
   232                }
   233              ],
   234              "ordered": true,
   235              "lsid": "session0",
   236              "txnNumber": {
   237                "$numberLong": "1"
   238              },
   239              "autocommit": false,
   240              "readConcern": null,
   241              "startTransaction": null,
   242              "writeConcern": null
   243            },
   244            "command_name": "insert",
   245            "database_name": "withTransaction-tests"
   246          }
   247        },
   248        {
   249          "command_started_event": {
   250            "command": {
   251              "commitTransaction": 1,
   252              "lsid": "session0",
   253              "txnNumber": {
   254                "$numberLong": "1"
   255              },
   256              "autocommit": false,
   257              "readConcern": null,
   258              "startTransaction": null,
   259              "writeConcern": null
   260            },
   261            "command_name": "commitTransaction",
   262            "database_name": "admin"
   263          }
   264        },
   265        {
   266          "command_started_event": {
   267            "command": {
   268              "insert": "test",
   269              "documents": [
   270                {
   271                  "_id": 3
   272                }
   273              ],
   274              "ordered": true,
   275              "lsid": "session0",
   276              "autocommit": null,
   277              "readConcern": null,
   278              "startTransaction": null,
   279              "writeConcern": null
   280            },
   281            "command_name": "insert",
   282            "database_name": "withTransaction-tests"
   283          }
   284        }
   285      ],
   286      "outcome": {
   287        "collection": {
   288          "data": [
   289            {
   290              "_id": 1
   291            },
   292            {
   293              "_id": 2
   294            },
   295            {
   296              "_id": 3
   297            }
   298          ]
   299        }
   300      }
   301    }
   302  ]
   303}

View as plain text