diff options
author | Benety Goh <benety@mongodb.com> | 2022-09-19 08:48:17 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-04-19 18:35:36 +0000 |
commit | d750ce3640ef43b11b9967636ed8428495c53f1b (patch) | |
tree | d3a79f423571bef86e27d0caec34272e5ab0d2b7 | |
parent | de389c26a0098aedc3b69c9aec2849ceac10a06b (diff) | |
download | mongo-d750ce3640ef43b11b9967636ed8428495c53f1b.tar.gz |
SERVER-69783 add test case for TTL index with floating point 'expireAfterSeconds'
(cherry picked from commit fc98fdb6d67eb51112fcb72d82a561d580ee085a)
-rw-r--r-- | src/mongo/db/catalog/index_key_validate_test.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/mongo/db/catalog/index_key_validate_test.cpp b/src/mongo/db/catalog/index_key_validate_test.cpp index 24f06cc1b86..5a0b7391338 100644 --- a/src/mongo/db/catalog/index_key_validate_test.cpp +++ b/src/mongo/db/catalog/index_key_validate_test.cpp @@ -334,6 +334,14 @@ TEST(IndexKeyValidateTest, UpdateTTLIndexNaNExpireAfterSeconds) { nullptr, fromjson("{key: {a: 1}, name: 'index', expireAfterSeconds: NaN}"))))); } +TEST(IndexKeyValidateTest, ValidateAfterSecondsAcceptsFloatingPointNumber) { + auto spec = unittest::assertGet(index_key_validate::validateIndexSpec( + nullptr, fromjson("{key: {a: 1}, name: 'index', expireAfterSeconds: 123.456}"))); + + // TTLMonitor extracts 'expireAfterSeconds' using BSONElement::safeNumberLong(). + ASSERT_EQUALS(spec["expireAfterSeconds"].safeNumberLong(), 123LL); +} + TEST(IndexKeyValidateTest, RepairIndexSpecs) { ASSERT(fromjson("{key: {a: 1}, name: 'index'}") .binaryEqual(index_key_validate::repairIndexSpec( |