✨ Add “show metrics” debug information flag
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 28 Jul 2019 11:17:02 +0000 (13:17 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 28 Jul 2019 11:17:02 +0000 (13:17 +0200)
src/main/kotlin/net/pterodactylus/sone/core/DebugInformation.kt
src/main/kotlin/net/pterodactylus/sone/main/SoneModule.kt
src/test/kotlin/net/pterodactylus/sone/core/DebugInformationTest.kt
src/test/kotlin/net/pterodactylus/sone/main/SoneModuleTest.kt

index acb0155..3115b87 100644 (file)
@@ -22,4 +22,7 @@ class DebugInformation {
        @Volatile
        var showVersionInformation = false
 
+       @Volatile
+       var showMetrics = false
+
 }
index 8f018f5..6657486 100644 (file)
@@ -67,6 +67,7 @@ open class SoneModule(private val sonePlugin: SonePlugin, private val eventBus:
        fun getCore(configuration: Configuration, freenetInterface: FreenetInterface, identityManager: IdentityManager, soneDownloader: SoneDownloader, imageInserter: ImageInserter, updateChecker: UpdateChecker, webOfTrustUpdater: WebOfTrustUpdater, eventBus: EventBus, database: Database) =
                        Core(configuration, freenetInterface, identityManager, soneDownloader, imageInserter, updateChecker, webOfTrustUpdater, eventBus, database).apply {
                                debugInformation.showVersionInformation = configuration.getBooleanValue("Debug/ShowVersionInformation").getValue(false)
+                               debugInformation.showMetrics = configuration.getBooleanValue("Debug/ShowMetrics").getValue(false)
                        }.also(eventBus::register)
 
 }
index 5ec1ea9..6813253 100644 (file)
@@ -30,4 +30,9 @@ class DebugInformationTest {
                assertThat(debugInformation.showVersionInformation, equalTo(false))
        }
 
+       @Test
+       fun `new debug information has show metrics set to off`() {
+               assertThat(debugInformation.showMetrics, equalTo(false))
+       }
+
 }
index 526c089..d125769 100644 (file)
@@ -108,6 +108,12 @@ class SoneModuleTest {
        }
 
        @Test
+       fun `show metrics debug information flag is read from config`() {
+               File(currentDir, "sone.properties").writeText("Debug/ShowMetrics=true")
+               assertThat(injector.getInstance<Core>().debugInformation.showMetrics, equalTo(true))
+       }
+
+       @Test
        fun `event bus is bound`() {
                assertThat(injector.getInstance<EventBus>(), notNullValue())
        }