mongo/jstests/sharding/read_does_not_create_namespaces.js
Steve McClure 1ffbc6c2e9 SERVER-109432: Autofix JS var usage to favor let (#40637)
GitOrigin-RevId: 9674b7db36a0f3f650d39c1e3fb2ad6ff2141cfb
2025-08-28 19:21:01 +00:00

15 lines
643 B
JavaScript

// This test ensures that just attempting to read from a non-existent database or collection won't
// cause entries to be created in the catalog.
import {ShardingTest} from "jstests/libs/shardingtest.js";
let shardingTest = new ShardingTest({name: "read_does_not_create_namespaces", shards: 1});
var db = shardingTest.getDB("NonExistentDB");
assert.isnull(db.nonExistentColl.findOne({}));
// Neither the database nor the collection should have been created
assert.isnull(shardingTest.getDB("config").databases.findOne({_id: "NonExistentDB"}));
assert.eq(-1, shardingTest.shard0.getDBNames().indexOf("NonExistentDB"));
shardingTest.stop();