summaryrefslogtreecommitdiff
path: root/jstests/core/timeseries/timeseries_list_collections_missing_view.js
blob: 12fd1ef2297cade7c20e8426533f9c7d34243e91 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/**
 * Tests that listCollections shows the time-series buckets collection, but not the view, if the
 * time-series view is missing.
 *
 * @tags: [
 *   assumes_no_implicit_collection_creation_after_drop,
 *   does_not_support_transactions,
 *   requires_getmore,
 * ]
 */
(function() {
'use strict';

const testDB = db.getSiblingDB(jsTestName());
assert.commandWorked(testDB.dropDatabase());

const timeFieldName = 'time';
const coll = testDB.getCollection('t');

assert.commandWorked(
    testDB.createCollection(coll.getName(), {timeseries: {timeField: timeFieldName}}));
assert(testDB.system.views.drop());

const collections = assert.commandWorked(testDB.runCommand({listCollections: 1})).cursor.firstBatch;
jsTestLog('Checking listCollections result: ' + tojson(collections));
assert.eq(collections.length, 1);
assert(collections.find(entry => entry.name === 'system.buckets.' + coll.getName()));
})();