summaryrefslogtreecommitdiff
path: root/jstests/noPassthroughWithMongod/timeseries_system_views_drop.js
blob: 8adf9ad391cc451bc201bf93f0c39bdf88a2547f (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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/**
 * Tests that the system.views collection cannot be dropped if time-series collections are present.
 *
 * @tags: [
 *   assumes_no_implicit_collection_creation_after_drop,
 *   does_not_support_stepdowns,
 *   does_not_support_transactions,
 *   requires_getmore,
 * ]
 */
(function() {
"use strict";

load("jstests/core/timeseries/libs/timeseries.js");

const testDB = db.getSiblingDB("timeseries_system_views_drop");

TimeseriesTest.run((insert) => {
    const tsColl = testDB.timeseries_system_views_drop;
    const timeFieldName = 'time';

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

    assert.eq(testDB.system.views.find().toArray().length, 1);
    assert.throws(() => {
        testDB.system.views.drop();
    });

    assert(tsColl.drop());
    assert.eq(testDB.system.views.find().toArray().length, 0);

    const coll = testDB.my_coll;

    coll.drop();
    assert.commandWorked(testDB.createCollection(coll.getName()));
    assert.commandWorked(testDB.createView("myView", coll.getName(), []));

    assert(testDB.system.views.drop());
});
})();