Skip to content

Commit c1913e4

Browse files
author
Taichi Yamakawa
committed
Test SnapshotStore should persist nothing if it has the same EntitySnapshot
1 parent 86a8db4 commit c1913e4

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/test/scala/lerna/akka/entityreplication/raft/snapshot/ShardSnapshotStoreSuccessSpec.scala

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,24 @@ class ShardSnapshotStoreSuccessSpec
4848
expectMsg(SaveSnapshotSuccess(metadata))
4949
}
5050

51+
"persist nothing and reply with SaveSnapshotSuccess to SaveSnapshot if it has the same EntitySnapshot" in {
52+
val entityId = generateUniqueEntityId()
53+
val shardSnapshotStore = createShardSnapshotStore()
54+
val snapshotStorePersistenceId = SnapshotStore.persistenceId(typeName, entityId, memberIndex)
55+
val metadata = EntitySnapshotMetadata(entityId, LogEntryIndex.initial())
56+
val snapshot = EntitySnapshot(metadata, dummyEntityState)
57+
58+
// Prepare:
59+
shardSnapshotStore ! SaveSnapshot(snapshot, replyTo = testActor)
60+
snapshotTestKit.expectNextPersisted(snapshotStorePersistenceId, snapshot)
61+
expectMsg(SaveSnapshotSuccess(metadata))
62+
63+
// Test:
64+
shardSnapshotStore ! SaveSnapshot(snapshot, replyTo = testActor)
65+
snapshotTestKit.expectNothingPersisted(snapshotStorePersistenceId)
66+
expectMsg(SaveSnapshotSuccess(metadata))
67+
}
68+
5169
"FetchSnapshot に成功した場合は一度停止しても SnapshotFound でスナップショットが返信される" in {
5270
val entityId = generateUniqueEntityId()
5371
val shardSnapshotStore = createShardSnapshotStore()

0 commit comments

Comments
 (0)