Apply per-event notification logging rules
This commit is contained in:
+27
@@ -0,0 +1,27 @@
|
||||
package se.ajpanton.notificationlog.settings
|
||||
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
class NotificationRuleEvaluatorTest {
|
||||
@Test fun `default blacklist allows every app`() {
|
||||
assertTrue(NotificationRuleEvaluator.allows(LoggingRule(), "example.app"))
|
||||
}
|
||||
|
||||
@Test fun `blacklist excludes selected app`() {
|
||||
val rule = LoggingRule(selectedPackages = setOf("example.app"))
|
||||
assertFalse(NotificationRuleEvaluator.allows(rule, "example.app"))
|
||||
assertTrue(NotificationRuleEvaluator.allows(rule, "other.app"))
|
||||
}
|
||||
|
||||
@Test fun `whitelist accepts only selected app`() {
|
||||
val rule = LoggingRule(appRuleMode = AppRuleMode.WHITELIST, selectedPackages = setOf("example.app"))
|
||||
assertTrue(NotificationRuleEvaluator.allows(rule, "example.app"))
|
||||
assertFalse(NotificationRuleEvaluator.allows(rule, "other.app"))
|
||||
}
|
||||
|
||||
@Test fun `disabled rule rejects selected app`() {
|
||||
assertFalse(NotificationRuleEvaluator.allows(LoggingRule(enabled = false), "example.app"))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user