aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at
diff options
context:
space:
mode:
authorThunderblade73 <85900443+Thunderblade73@users.noreply.github.com>2024-04-25 10:35:33 +0200
committerGitHub <noreply@github.com>2024-04-25 10:35:33 +0200
commitb5ea959544aa5133f1763ed23268ce45f11998b1 (patch)
tree67d5e76ca113921080cbfa5b49ebf35b95b37a24 /src/main/java/at
parentb4fae219f4953647df088e78b1b63b70da4a7dac (diff)
downloadskyhanni-b5ea959544aa5133f1763ed23268ce45f11998b1.tar.gz
skyhanni-b5ea959544aa5133f1763ed23268ce45f11998b1.tar.bz2
skyhanni-b5ea959544aa5133f1763ed23268ce45f11998b1.zip
Backend: Unit Test RepoPatterns (#1410)
Diffstat (limited to 'src/main/java/at')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/repopatterns/RepoPatternManager.kt12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/repopatterns/RepoPatternManager.kt b/src/main/java/at/hannibal2/skyhanni/utils/repopatterns/RepoPatternManager.kt
index 26452e58f..09cd4f730 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/repopatterns/RepoPatternManager.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/repopatterns/RepoPatternManager.kt
@@ -49,16 +49,18 @@ object RepoPatternManager {
private val insideTest = Launch.blackboard == null
+ var inTestDuplicateUsage = true
+
private val config
get() = if (!insideTest) {
SkyHanniMod.feature.dev.repoPattern
} else {
RepoPatternConfig().apply {
- tolerateDuplicateUsage = true
+ tolerateDuplicateUsage = inTestDuplicateUsage
}
}
- val localLoading: Boolean get() = config.forceLocal.get() || LorenzUtils.isInDevEnvironment()
+ val localLoading: Boolean get() = config.forceLocal.get() || (!insideTest && LorenzUtils.isInDevEnvironment())
/**
* Crash if in a development environment, or if inside a guarded event handler.
@@ -86,8 +88,12 @@ object RepoPatternManager {
@SubscribeEvent
fun onRepoReload(event: RepositoryReloadEvent) {
+ loadPatternsFromDump(event.getConstant<RepoPatternDump>("regexes"))
+ }
+
+ fun loadPatternsFromDump(dump: RepoPatternDump) {
regexes = null
- regexes = event.getConstant<RepoPatternDump>("regexes")
+ regexes = dump
reloadPatterns()
}