0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-27 23:27:11 +01:00
mongodb/jstests/noPassthrough/missing_shard_key.js
Matt Broadstone 771dabd098 SERVER-81339 Convert ReplSetTest and ShardingTest to modules (#26332)
GitOrigin-RevId: 744aa110a53786b23c62ff53f87a1418b5991e8d
2024-08-20 22:00:49 +00:00

19 lines
562 B
JavaScript

/**
* Verify that a query requiring shard filtering handles missing shard keys properly.
*/
import {ShardingTest} from "jstests/libs/shardingtest.js";
const st = new ShardingTest({
shards: 1,
});
const dbName = "foo";
const ns = "foo.bar";
assert.commandWorked(st.s.adminCommand({enableSharding: dbName}));
assert.commandWorked(st.s.adminCommand({shardCollection: ns, key: {skey: 1}}));
assert.commandWorked(st.s.getCollection(ns).insert({_id: 1, x: 1}));
assert.sameMembers(st.s.getCollection(ns).find({x: 1}).toArray(), [{_id: 1, x: 1}]);
st.stop();