From e6deb004dfb74bbf0c381597185ea7cf88a9a812 Mon Sep 17 00:00:00 2001 From: Benety Goh Date: Thu, 14 Nov 2019 23:20:50 +0000 Subject: SERVER-44619 add expected error code to test --- jstests/core/indexu.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/jstests/core/indexu.js b/jstests/core/indexu.js index 0e68429eaf7..d430f936696 100644 --- a/jstests/core/indexu.js +++ b/jstests/core/indexu.js @@ -12,7 +12,7 @@ var noDupDoc = {a: [{'1': 1}]}; // Test that we can't index dupDoc. assert.commandWorked(t.save(dupDoc)); -assert.commandFailed(t.ensureIndex({'a.0': 1})); +assert.commandFailedWithCode(t.ensureIndex({'a.0': 1}), 16746); // Test that we can fail gracefully when dupDoc has a large array padded with nulls. // Index is based on max padding constant in mongo/db/update/path_support.h @@ -26,7 +26,7 @@ assert.writeError(t.save(dupDoc)); // Test that we can't index dupDoc2. t.drop(); assert.commandWorked(t.save(dupDoc2)); -assert.commandFailed(t.ensureIndex({'a.1': 1})); +assert.commandFailedWithCode(t.ensureIndex({'a.1': 1}), 16746); t.remove({}); assert.commandWorked(t.ensureIndex({'a.1': 1})); @@ -86,28 +86,28 @@ assert.commandFailed(t.ensureIndex({'a.0.0': 1})); // Check where there is a duplicate for a fully addressed field. t.drop(); assert.commandWorked(t.save({a: [[1], {'0': [1]}]})); -assert.commandFailed(t.ensureIndex({'a.0.0': 1})); +assert.commandFailedWithCode(t.ensureIndex({'a.0.0': 1}), 16746); // Two ways of addressing parse to an array. t.drop(); t.save({a: [{'0': 1}]}); -assert.commandFailed(t.ensureIndex({'a.0.0': 1})); +assert.commandFailedWithCode(t.ensureIndex({'a.0.0': 1}), 16746); // Test several key depths - with same arrays being found. t.drop(); t.save({a: [{'0': [{'0': 1}]}]}); -assert.commandFailed(t.ensureIndex({'a.0.0.0.0.0.0': 1})); -assert.commandFailed(t.ensureIndex({'a.0.0.0.0.0': 1})); -assert.commandFailed(t.ensureIndex({'a.0.0.0.0': 1})); -assert.commandFailed(t.ensureIndex({'a.0.0.0': 1})); -assert.commandFailed(t.ensureIndex({'a.0.0': 1})); -assert.commandFailed(t.ensureIndex({'a.0': 1})); +assert.commandFailedWithCode(t.ensureIndex({'a.0.0.0.0.0.0': 1}), 16746); +assert.commandFailedWithCode(t.ensureIndex({'a.0.0.0.0.0': 1}), 16746); +assert.commandFailedWithCode(t.ensureIndex({'a.0.0.0.0': 1}), 16746); +assert.commandFailedWithCode(t.ensureIndex({'a.0.0.0': 1}), 16746); +assert.commandFailedWithCode(t.ensureIndex({'a.0.0': 1}), 16746); +assert.commandFailedWithCode(t.ensureIndex({'a.0': 1}), 16746); assert.commandWorked(t.ensureIndex({'a': 1})); // Two prefixes extract docs, but one terminates extraction before array. t.drop(); t.save({a: [{'0': {'c': []}}]}); -assert.commandFailed(t.ensureIndex({'a.0.c': 1})); +assert.commandFailedWithCode(t.ensureIndex({'a.0.c': 1}), 16746); t.drop(); t.save({a: [[{'b': 1}]]}); -- cgit v1.2.1