...

Text file src/go.mongodb.org/mongo-driver/testdata/unified-test-format/valid-pass/entity-commandCursor.yml

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

     1description: entity-commandCursor
     2schemaVersion: '1.3'
     3createEntities:
     4  - client:
     5      id: &client client
     6      useMultipleMongoses: false
     7      observeEvents: [commandStartedEvent]
     8  - database:
     9      id: &db db
    10      client: *client
    11      databaseName: *db
    12  - collection:
    13      id: &collection collection
    14      database: *db
    15      collectionName: *collection
    16initialData:
    17  - collectionName: collection
    18    databaseName: *db
    19    documents: &documents
    20      - { _id: 1, x: 11 }
    21      - { _id: 2, x: 22 }
    22      - { _id: 3, x: 33 }
    23      - { _id: 4, x: 44 }
    24      - { _id: 5, x: 55 }
    25tests:
    26  - description: runCursorCommand creates and exhausts cursor by running getMores
    27    operations:
    28      - name: runCursorCommand
    29        object: *db
    30        arguments:
    31          commandName: find
    32          batchSize: 2
    33          command: { find: *collection, filter: {}, batchSize: 2 }
    34        expectResult: *documents
    35    expectEvents:
    36      - client: *client
    37        events:
    38          - commandStartedEvent:
    39              command:
    40                find: *collection
    41                filter: {}
    42                batchSize: 2
    43                $db: *db
    44                lsid: { $$exists: true }
    45              commandName: find
    46          - commandStartedEvent:
    47              command:
    48                getMore: { $$type: [int, long] }
    49                collection: *collection
    50                $db: *db
    51                lsid: { $$exists: true }
    52              commandName: getMore
    53          - commandStartedEvent:
    54              command:
    55                getMore: { $$type: [int, long] }
    56                collection: *collection
    57                $db: *db
    58                lsid: { $$exists: true }
    59              commandName: getMore
    60
    61  - description: createCommandCursor creates a cursor and stores it as an entity that can be iterated one document at a time
    62    operations:
    63      - name: createCommandCursor
    64        object: *db
    65        arguments:
    66          commandName: find
    67          batchSize: 2
    68          command: { find: *collection, filter: {}, batchSize: 2 }
    69        saveResultAsEntity: &myRunCommandCursor myRunCommandCursor
    70      - name: iterateUntilDocumentOrError
    71        object: *myRunCommandCursor
    72        expectResult: { _id: 1, x: 11 }
    73      - name: iterateUntilDocumentOrError
    74        object: *myRunCommandCursor
    75        expectResult: { _id: 2, x: 22 }
    76      - name: iterateUntilDocumentOrError
    77        object: *myRunCommandCursor
    78        expectResult: { _id: 3, x: 33 }
    79      - name: iterateUntilDocumentOrError
    80        object: *myRunCommandCursor
    81        expectResult: { _id: 4, x: 44 }
    82      - name: iterateUntilDocumentOrError
    83        object: *myRunCommandCursor
    84        expectResult: { _id: 5, x: 55 }
    85
    86  - description: createCommandCursor's cursor can be closed and will perform a killCursors operation
    87    operations:
    88      - name: createCommandCursor
    89        object: *db
    90        arguments:
    91          commandName: find
    92          batchSize: 2
    93          command: { find: *collection, filter: {}, batchSize: 2 }
    94        saveResultAsEntity: myRunCommandCursor
    95      - name: iterateUntilDocumentOrError
    96        object: *myRunCommandCursor
    97        expectResult: { _id: 1, x: 11 }
    98      - name: close
    99        object: *myRunCommandCursor
   100    expectEvents:
   101      - client: *client
   102        events:
   103          - commandStartedEvent:
   104              command:
   105                find: *collection
   106                filter: {}
   107                batchSize: 2
   108                $db: *db
   109                lsid: { $$exists: true }
   110              commandName: find
   111          - commandStartedEvent:
   112              command:
   113                killCursors: *collection
   114                cursors: { $$type: array }
   115              commandName: killCursors

View as plain text