From: David ‘Bombe’ Roden Date: Sun, 24 Feb 2019 09:50:14 +0000 (+0100) Subject: Add test for storing IDs on known post replies X-Git-Tag: v79^2~92 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=b798049da3b4d4a58d5ff12314bc1022808171bc;p=Sone.git Add test for storing IDs on known post replies --- diff --git a/src/main/java/net/pterodactylus/sone/database/memory/MemoryDatabase.kt b/src/main/java/net/pterodactylus/sone/database/memory/MemoryDatabase.kt index 962357e..d7e84e5 100644 --- a/src/main/java/net/pterodactylus/sone/database/memory/MemoryDatabase.kt +++ b/src/main/java/net/pterodactylus/sone/database/memory/MemoryDatabase.kt @@ -298,6 +298,7 @@ class MemoryDatabase @Inject constructor(private val configuration: Configuratio knownPostReplies.add(postReply.id) else knownPostReplies.remove(postReply.id) + saveKnownPostReplies() } private fun loadKnownPosts() = diff --git a/src/test/java/net/pterodactylus/sone/database/memory/MemoryDatabaseTest.java b/src/test/java/net/pterodactylus/sone/database/memory/MemoryDatabaseTest.java index 0d20aad..60c8c53 100644 --- a/src/test/java/net/pterodactylus/sone/database/memory/MemoryDatabaseTest.java +++ b/src/test/java/net/pterodactylus/sone/database/memory/MemoryDatabaseTest.java @@ -466,4 +466,14 @@ public class MemoryDatabaseTest { assertThat(configuration.getStringValue("KnownPosts/1/ID").getValue(), equalTo(null)); } + @Test + public void markingAPostReplyAsKnownSavesConfiguration() throws ConfigurationException { + prepareConfigurationValues(); + PostReply postReply = mock(PostReply.class); + when(postReply.getId()).thenReturn("post-reply-id"); + memoryDatabase.setPostReplyKnown(postReply, true); + assertThat(configuration.getStringValue("KnownReplies/0/ID").getValue(), equalTo("post-reply-id")); + assertThat(configuration.getStringValue("KnownReplies/1/ID").getValue(), equalTo(null)); + } + }