File tree Expand file tree Collapse file tree
app/src/main/kotlin/io/tolgee/ee/component/limitsAndReporting/generic
tests/src/test/kotlin/io/tolgee/ee/unit/limitsAndReporting Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ open class GenericLimitChecker(
1717 fun check (required : Long? ) = check { required }
1818
1919 fun check (requiredProvider : () -> Long? ) {
20- if (limit.limit <= 0 ) {
20+ if (limit.limit < 0 ) {
2121 return
2222 }
2323
Original file line number Diff line number Diff line change @@ -30,19 +30,12 @@ class GenericLimitCheckerTest {
3030 )
3131
3232 @Test
33- fun `zero limit - no exception and provider not called` () {
34- var providerCalled = false
35- val checker =
36- checker(
37- zeroLimit(),
38- includedProvider = {
39- providerCalled = true
40- RuntimeException ()
41- },
42- )
33+ fun `zero limit - throws included exception (not treated as unlimited)` () {
34+ val checker = checker(zeroLimit())
4335
44- assertDoesNotThrow { checker.check { 999L } }
45- assertFalse(providerCalled)
36+ val ex = assertThrows<RuntimeException > { checker.check { 999L } }
37+
38+ assert (ex.message == " included: 999" )
4639 }
4740
4841 @Test
Original file line number Diff line number Diff line change @@ -5,7 +5,6 @@ import io.tolgee.ee.component.limitsAndReporting.generic.KeysLimitChecker
55import io.tolgee.exceptions.limits.PlanLimitExceededKeysException
66import io.tolgee.exceptions.limits.PlanSpendingLimitExceededKeysException
77import org.assertj.core.api.Assertions.assertThat
8- import org.junit.jupiter.api.Assertions.assertDoesNotThrow
98import org.junit.jupiter.api.Test
109import org.junit.jupiter.api.assertThrows
1110
@@ -25,9 +24,10 @@ class KeysLimitCheckerTest {
2524 )
2625
2726 @Test
28- fun `zero keys limit - no exception (unlimited detection bug fix )` () {
27+ fun `zero keys limit - throws PlanLimitExceededKeysException (zero is a real limit )` () {
2928 val checker = KeysLimitChecker (usageLimits(keys = UsageLimits .Limit (included = 0 , limit = 0 )))
30- assertDoesNotThrow { checker.check { 999L } }
29+
30+ assertThrows<PlanLimitExceededKeysException > { checker.check { 999L } }
3131 }
3232
3333 @Test
Original file line number Diff line number Diff line change @@ -5,7 +5,6 @@ import io.tolgee.ee.component.limitsAndReporting.generic.StringsLimitChecker
55import io.tolgee.exceptions.limits.PlanLimitExceededStringsException
66import io.tolgee.exceptions.limits.PlanSpendingLimitExceededStringsException
77import org.assertj.core.api.Assertions.assertThat
8- import org.junit.jupiter.api.Assertions.assertDoesNotThrow
98import org.junit.jupiter.api.Test
109import org.junit.jupiter.api.assertThrows
1110
@@ -25,9 +24,10 @@ class StringsLimitCheckerTest {
2524 )
2625
2726 @Test
28- fun `zero strings limit - no exception (unlimited detection bug fix )` () {
27+ fun `zero strings limit - throws PlanLimitExceededStringsException (zero is a real limit )` () {
2928 val checker = StringsLimitChecker (usageLimits(strings = UsageLimits .Limit (included = 0 , limit = 0 )))
30- assertDoesNotThrow { checker.check { 999L } }
29+
30+ assertThrows<PlanLimitExceededStringsException > { checker.check { 999L } }
3131 }
3232
3333 @Test
You can’t perform that action at this time.
0 commit comments