From: David ‘Bombe’ Roden Date: Tue, 3 Dec 2019 17:54:19 +0000 (+0100) Subject: ✨ Add loaders implementation for tests X-Git-Tag: v81^2~5^2~82 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=1d5c4b25daebb9c64044072c15db14c29c1ed900;p=Sone.git ✨ Add loaders implementation for tests --- diff --git a/src/test/kotlin/net/pterodactylus/sone/test/TestLoaders.kt b/src/test/kotlin/net/pterodactylus/sone/test/TestLoaders.kt new file mode 100644 index 0000000..f71e9f5 --- /dev/null +++ b/src/test/kotlin/net/pterodactylus/sone/test/TestLoaders.kt @@ -0,0 +1,21 @@ +package net.pterodactylus.sone.test + +import net.pterodactylus.sone.main.* +import net.pterodactylus.util.template.* +import net.pterodactylus.util.web.* + +/** + * [Loaders] implementation for use in tests. Use [templates] to control what templates are + * returned by the [loadTemplate] method. + */ +class TestLoaders : Loaders { + + val templates = mutableMapOf() + + override fun loadTemplate(path: String) = templates[path] ?: Template() + + override fun loadStaticPage(basePath: String, prefix: String, mimeType: String) = TestPage() + + override fun getTemplateProvider() = TemplateProvider { _, _ -> Template() } + +}