summaryrefslogtreecommitdiff
path: root/jstests/core/views/duplicate_ns.js
blob: d4d15125f637290cbcf741d51e274282ab9731dd (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
// Test the creation of view with a duplicate name to a collection.

(function() {
    "use strict";

    const dbName = "views_duplicate_ns";
    const viewsDb = db.getSiblingDB(dbName);
    const collName = "myns";
    const viewId = dbName + "." + collName;

    assert.commandWorked(viewsDb.dropDatabase());
    assert.writeOK(viewsDb.system.views.remove({_id: viewId}));
    assert.commandWorked(viewsDb.runCommand({create: collName}));
    assert.writeOK(viewsDb.system.views.insert({
        _id: viewId,
        viewOn: "coll",
        pipeline: [],
    }));
    assert.eq(2,
              viewsDb.getCollectionInfos()
                  .filter(coll => {
                      return coll.name === collName;
                  })
                  .length);
}());