summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough
diff options
context:
space:
mode:
authorJames Wahlin <james@mongodb.com>2020-05-29 11:06:32 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-06-12 14:22:54 +0000
commit56ef6a8f586e58f2d23911226c7880a7b678e0af (patch)
treeb754496882ff868a2a1e981d78f35f90333518bf /jstests/noPassthrough
parent4bd561c80d376130cf851fed23d1261ac36179fc (diff)
downloadmongo-56ef6a8f586e58f2d23911226c7880a7b678e0af.tar.gz
SERVER-44273 Fix timeZoneInfo file load on Windows
Diffstat (limited to 'jstests/noPassthrough')
-rw-r--r--jstests/noPassthrough/parse_zone_info.js17
1 files changed, 16 insertions, 1 deletions
diff --git a/jstests/noPassthrough/parse_zone_info.js b/jstests/noPassthrough/parse_zone_info.js
index 9e9343e020f..c9836de08e3 100644
--- a/jstests/noPassthrough/parse_zone_info.js
+++ b/jstests/noPassthrough/parse_zone_info.js
@@ -1,4 +1,4 @@
-// Tests the parsing of the timeZoneInfo parameter.
+// Tests the parsing of the timeZoneInfo parameter and file use.
(function() {
// Test that a bad file causes startup to fail.
let conn = MongoRunner.runMongod({timeZoneInfo: "jstests/libs/config_files/bad_timezone_info"});
@@ -16,5 +16,20 @@ assert(rawMongoProgramOutput().includes("Error creating service context") ||
// Test that startup can succeed with a good file.
conn = MongoRunner.runMongod({timeZoneInfo: "jstests/libs/config_files/good_timezone_info"});
assert.neq(conn, null, "expected launching mongod with good timezone rules to succeed");
+
+// Test that can use file-provided timezones in an expression.
+const testDB = conn.getDB("test");
+const coll = testDB.parse_zone_info;
+assert.commandWorked(coll.insert({x: new Date()}));
+assert.doesNotThrow(
+ () => coll.aggregate([{$set: {x_parts: {$dateToParts: {date: "$x", timezone: "GMT"}}}}]));
+assert.doesNotThrow(
+ () => coll.aggregate(
+ [{$set: {x_parts: {$dateToParts: {date: "$x", timezone: "America/Sao_Paulo"}}}}]));
+
+// Confirm that attempt to use a non-existent timezone in an expression fails.
+const err = assert.throws(
+ () => coll.aggregate([{$set: {x_parts: {$dateToParts: {date: "$x", timezone: "Unknown"}}}}]));
+assert.eq(err.code, 40485);
MongoRunner.stopMongod(conn);
}());