aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/at/hannibal2/skyhanni
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/test/java/at/hannibal2/skyhanni
parentb4fae219f4953647df088e78b1b63b70da4a7dac (diff)
downloadskyhanni-b5ea959544aa5133f1763ed23268ce45f11998b1.tar.gz
skyhanni-b5ea959544aa5133f1763ed23268ce45f11998b1.tar.bz2
skyhanni-b5ea959544aa5133f1763ed23268ce45f11998b1.zip
Backend: Unit Test RepoPatterns (#1410)
Diffstat (limited to 'src/test/java/at/hannibal2/skyhanni')
-rw-r--r--src/test/java/at/hannibal2/skyhanni/test/RepoPatternTest.kt51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/test/java/at/hannibal2/skyhanni/test/RepoPatternTest.kt b/src/test/java/at/hannibal2/skyhanni/test/RepoPatternTest.kt
new file mode 100644
index 000000000..46c2fb619
--- /dev/null
+++ b/src/test/java/at/hannibal2/skyhanni/test/RepoPatternTest.kt
@@ -0,0 +1,51 @@
+package at.hannibal2.skyhanni.test
+
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPatternDump
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPatternManager
+import org.junit.jupiter.api.Test
+import org.junit.jupiter.api.assertThrows
+
+object RepoPatternTest {
+
+ @Test
+ fun testRemoteLoad() {
+ val simpleLocalePattern = "I'm a test value"
+
+ val simpleRepoPattern = RepoPattern.pattern("testonly.a", simpleLocalePattern)
+ val simplePattern by simpleRepoPattern
+
+ val remoteValue = "I'm remote."
+
+ val isLocalWorking = simplePattern.pattern() == simpleLocalePattern
+
+ assert(isLocalWorking)
+
+ RepoPatternManager.loadPatternsFromDump(
+ RepoPatternDump(
+ regexes = mapOf(
+ simpleRepoPattern.key to remoteValue
+ )
+ )
+ )
+
+ val isRemoteWorking = simplePattern.pattern() == remoteValue
+
+ assert(isRemoteWorking)
+
+ }
+
+ @Test
+ fun testExclusivity() {
+ RepoPatternManager.inTestDuplicateUsage = false
+
+ assertThrows<RuntimeException> {
+ val pattern1 by RepoPattern.pattern("testonly.b", "")
+ val pattern2 by RepoPattern.pattern("testonly.b", "")
+ pattern1
+ pattern2
+ }
+
+ RepoPatternManager.inTestDuplicateUsage = true
+ }
+}