diff options
author | clang-format-7.0.1 <adam.martin@10gen.com> | 2019-07-26 18:20:35 -0400 |
---|---|---|
committer | ADAM David Alan Martin <adam.martin@10gen.com> | 2019-07-27 11:02:23 -0400 |
commit | 134a4083953270e8a11430395357fb70a29047ad (patch) | |
tree | dd428e1230e31d92b20b393dfdc17ffe7fa79cb6 /jstests/aggregation/sources/redact/collation_redact.js | |
parent | 1e46b5049003f427047e723ea5fab15b5a9253ca (diff) | |
download | mongo-134a4083953270e8a11430395357fb70a29047ad.tar.gz |
SERVER-41772 Apply clang-format 7.0.1 to the codebase
Diffstat (limited to 'jstests/aggregation/sources/redact/collation_redact.js')
-rw-r--r-- | jstests/aggregation/sources/redact/collation_redact.js | 67 |
1 files changed, 33 insertions, 34 deletions
diff --git a/jstests/aggregation/sources/redact/collation_redact.js b/jstests/aggregation/sources/redact/collation_redact.js index 36304e9a7f2..7ff1e1ad4f1 100644 --- a/jstests/aggregation/sources/redact/collation_redact.js +++ b/jstests/aggregation/sources/redact/collation_redact.js @@ -3,38 +3,37 @@ // Test that the $redact stage respects the collation. (function() { - "use strict"; - - var caseInsensitive = {collation: {locale: "en_US", strength: 2}}; - - var coll = db.collation_redact; - coll.drop(); - assert.writeOK(coll.insert({a: "a"})); - - // Test that $redact respects an explicit collation. Since the top-level of the document gets - // pruned, we end up redacting the entire document and returning no results. - assert.eq(0, - coll.aggregate([{$redact: {$cond: [{$eq: ["A", "a"]}, "$$PRUNE", "$$KEEP"]}}], - caseInsensitive) - .itcount()); - - coll.drop(); - assert.commandWorked(db.createCollection(coll.getName(), caseInsensitive)); - assert.writeOK(coll.insert({a: "a"})); - - // Test that $redact respects the inherited collation. Since the top-level of the document gets - // pruned, we end up redacting the entire document and returning no results. - assert.eq( - 0, - coll.aggregate([{$redact: {$cond: [{$eq: ["A", "a"]}, "$$PRUNE", "$$KEEP"]}}]).itcount()); - - // Test that a $match which can be optimized to be pushed before the $redact respects the - // collation. - assert.eq(1, coll.aggregate([{$redact: "$$KEEP"}, {$match: {a: "A"}}]).itcount()); - - // Comparison to the internal constants bound to the $$KEEP, $$PRUNE, and $$DESCEND variable - // should not respect the collation. - assert.throws(() => coll.aggregate([{$redact: "KEEP"}], caseInsensitive)); - assert.throws(() => coll.aggregate([{$redact: "PRUNE"}], caseInsensitive)); - assert.throws(() => coll.aggregate([{$redact: "REDACT"}], caseInsensitive)); +"use strict"; + +var caseInsensitive = {collation: {locale: "en_US", strength: 2}}; + +var coll = db.collation_redact; +coll.drop(); +assert.writeOK(coll.insert({a: "a"})); + +// Test that $redact respects an explicit collation. Since the top-level of the document gets +// pruned, we end up redacting the entire document and returning no results. +assert.eq( + 0, + coll.aggregate([{$redact: {$cond: [{$eq: ["A", "a"]}, "$$PRUNE", "$$KEEP"]}}], caseInsensitive) + .itcount()); + +coll.drop(); +assert.commandWorked(db.createCollection(coll.getName(), caseInsensitive)); +assert.writeOK(coll.insert({a: "a"})); + +// Test that $redact respects the inherited collation. Since the top-level of the document gets +// pruned, we end up redacting the entire document and returning no results. +assert.eq(0, + coll.aggregate([{$redact: {$cond: [{$eq: ["A", "a"]}, "$$PRUNE", "$$KEEP"]}}]).itcount()); + +// Test that a $match which can be optimized to be pushed before the $redact respects the +// collation. +assert.eq(1, coll.aggregate([{$redact: "$$KEEP"}, {$match: {a: "A"}}]).itcount()); + +// Comparison to the internal constants bound to the $$KEEP, $$PRUNE, and $$DESCEND variable +// should not respect the collation. +assert.throws(() => coll.aggregate([{$redact: "KEEP"}], caseInsensitive)); +assert.throws(() => coll.aggregate([{$redact: "PRUNE"}], caseInsensitive)); +assert.throws(() => coll.aggregate([{$redact: "REDACT"}], caseInsensitive)); })(); |