From b4d89eaaca9d374f693cff830411e12191efd1c0 Mon Sep 17 00:00:00 2001
From: Patrick Malouin
Date: Tue, 10 Mar 2020 17:25:43 -0400
Subject: [PATCH] fix: correctly use template string for connection string
error message
---
lib/connection_string.js | 2 +-
test/unit/core/connection_string.test.js | 7 +++++++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/lib/connection_string.js b/lib/connection_string.js
index b468a3b014..1aaf85f6f0 100644
--- a/lib/connection_string.js
+++ b/lib/connection_string.js
@@ -523,7 +523,7 @@ function assertTlsOptionsAreEqual(optionName, queryString, queryStringKeys) {
const firstValue = queryString[optionName][0];
queryString[optionName].forEach(tlsValue => {
if (tlsValue !== firstValue) {
- throw new MongoParseError('All values of ${optionName} must be the same.');
+ throw new MongoParseError(`All values of ${optionName} must be the same.`);
}
});
}
diff --git a/test/unit/core/connection_string.test.js b/test/unit/core/connection_string.test.js
index 3ddb05b7e2..470a9a7a33 100644
--- a/test/unit/core/connection_string.test.js
+++ b/test/unit/core/connection_string.test.js
@@ -203,6 +203,13 @@ describe('Connection String', function() {
done();
});
});
+
+ it('should validate non-equal tls values', function(done) {
+ parseConnectionString('mongodb://localhost/?tls=true&tls=false', err => {
+ expect(err).to.have.property('message', 'All values of tls must be the same.');
+ done();
+ });
+ });
});
describe('spec tests', function() {