⚡️ Only update configuration once per second
[Sone.git] / src / test / kotlin / net / pterodactylus / sone / database / memory / MemoryDatabaseTest.kt
index d02d162..4d7a105 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Sone - MemoryDatabaseTest.java - Copyright © 2013–2019 David Roden
+ * Sone - MemoryDatabaseTest.kt - Copyright © 2013–2019 David Roden
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -38,7 +38,7 @@ import kotlin.test.*
  */
 class MemoryDatabaseTest {
 
-       private val configuration = mock<Configuration>()
+       private val configuration = deepMock<Configuration>()
        private val memoryDatabase = MemoryDatabase(configuration)
        private val sone = mock<Sone>()
 
@@ -409,6 +409,14 @@ class MemoryDatabaseTest {
                assertThat(configuration.getStringValue("KnownReplies/1/ID").value, equalTo<Any>(null))
        }
 
+       @Test
+       @Dirty("the rate limiter should be mocked")
+       fun `saving the database twice in a row only saves it once`() {
+               memoryDatabase.save()
+               memoryDatabase.save()
+               verify(configuration.getStringValue("KnownPosts/0/ID"), times(1)).value = null
+       }
+
 }
 
 private const val SONE_ID = "sone"