Skip to content

Commit 078c946

Browse files
committed
tests, changelog
1 parent 23c280a commit 078c946

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- New API endpoints `DeleteAllByPrefix` and `PutMultipleVersions`. [#47](https://github.com/scalableminds/fossildb/pull/47)
55
- New API endpoints `GetMultipleKeysByListWithMultipleVersions` and `PutMultipleKeysWithMultipleVersions` for reading and writing multiple keys/versions in one request. [#48](https://github.com/scalableminds/fossildb/pull/48)
66
- `ListKeys` now supports optional `prefix` field
7+
- New API endpoint `GetMultipleKeysByList`. [#52](https://github.com/scalableminds/fossildb/pull/52)
78

89
## Breaking Changes
910

src/test/scala/com/scalableminds/fossildb/FossilDBSuite.scala

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,41 @@ class FossilDBSuite extends AnyFlatSpec with BeforeAndAfterEach with TestHelpers
441441
assert(reply.keyVersionsValuesPairs.isEmpty)
442442
}
443443

444+
"GetMultipleKeysByList" should "return version-value tuples for existing, and empty for missing keys" in {
445+
client.put(PutRequest(collectionA, aKey, Some(0), testData1))
446+
client.put(PutRequest(collectionA, aNotherKey, Some(0), testData2))
447+
client.put(PutRequest(collectionA, aNotherKey, Some(1), testData3))
448+
val reply = client.getMultipleKeysByList(GetMultipleKeysByListRequest(collectionA, keys = Seq(aKey, aNotherKey, aThirdKey)))
449+
assert(reply.versionValueBoxes.length == 3)
450+
assert(reply.versionValueBoxes(0).versionValuePair.exists(_.value == testData1))
451+
assert(reply.versionValueBoxes(1).versionValuePair.exists(_.value == testData3))
452+
assert(reply.versionValueBoxes(1).versionValuePair.exists(_.actualVersion == 1))
453+
assert(reply.versionValueBoxes(2).versionValuePair.isEmpty)
454+
}
455+
456+
it should "not return something newer than the requested version" in {
457+
client.put(PutRequest(collectionA, aKey, Some(0), testData1))
458+
client.put(PutRequest(collectionA, aNotherKey, Some(0), testData1))
459+
client.put(PutRequest(collectionA, aNotherKey, Some(1), testData2))
460+
client.put(PutRequest(collectionA, aNotherKey, Some(2), testData3))
461+
client.put(PutRequest(collectionA, aThirdKey, Some(2), testData3))
462+
val reply = client.getMultipleKeysByList(GetMultipleKeysByListRequest(collectionA, keys = Seq(aKey, aNotherKey, aThirdKey), version = Some(1)))
463+
assert(reply.versionValueBoxes.length == 3)
464+
assert(reply.versionValueBoxes(0).versionValuePair.exists(_.value == testData1))
465+
assert(reply.versionValueBoxes(0).versionValuePair.exists(_.actualVersion == 0))
466+
assert(reply.versionValueBoxes(1).versionValuePair.exists(_.value == testData2))
467+
assert(reply.versionValueBoxes(1).versionValuePair.exists(_.actualVersion == 1))
468+
assert(reply.versionValueBoxes(2).versionValuePair.isEmpty)
469+
}
470+
471+
it should "return only empty boxes if nothing matches" in {
472+
client.put(PutRequest(collectionA, aKey, Some(2), testData1))
473+
client.put(PutRequest(collectionA, aNotherKey, Some(2), testData1))
474+
val reply = client.getMultipleKeysByList(GetMultipleKeysByListRequest(collectionA, keys = Seq(aKey, aNotherKey, aThirdKey), version = Some(1)))
475+
assert(reply.versionValueBoxes.length == 3)
476+
assert(reply.versionValueBoxes.forall(_.versionValuePair.isEmpty))
477+
}
478+
444479
"Backup" should "create non-empty backup directory" in {
445480
client.put(PutRequest(collectionA, aKey, Some(0), testData1))
446481
client.backup(BackupRequest())

0 commit comments

Comments
 (0)