Skip to content

Commit

Permalink
Reverted "Created tests for when debug is false.".
Browse files Browse the repository at this point in the history
This reverts commit 5c96e9b4

(cherry picked from commit 091249c)
  • Loading branch information
Aristos Pasalides committed Dec 15, 2021
1 parent 72bb131 commit dd6833e
Showing 1 changed file with 0 additions and 57 deletions.
57 changes: 0 additions & 57 deletions src/test/kotlin/ktee/KTeeTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import org.slf4j.Logger
import org.slf4j.LoggerFactory
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
import kotlin.test.assertTrue

class KTeeTest {
Expand Down Expand Up @@ -65,60 +64,4 @@ class KTeeTest {
outputs.forEach { assertTrue { it.endsWith("hello myval" + System.lineSeparator()) } }
}

@Test
fun `should throw IllegalStateException`() {
assertFailsWith<IllegalStateException> {
KTee.debug = false; KTee.debug = false }
}

@Test
fun `should not write to stdout`() {
if (!KTee.debugChanged) KTee.debug = false
assertEquals("", trapOut { "myval".tee() })
}

@Test
fun `should not evaluate lambda or write to stdout`() {
if (!KTee.debugChanged) KTee.debug = false
assertEquals("", trapOut { "myval".tee { v -> "value is $v" } })
}

@Test
fun `should not write to logger`() {
if (!KTee.debugChanged) KTee.debug = false
assertTrue(trapErr { "myval".teeToInfo(logger) } == "")
}

@Test
fun `should not log with info level`() {
if (!KTee.debugChanged) KTee.debug = false
val outputs = listOf(
trapErr { "myval".teeToInfo(logger, "hello {}") },
trapErr { "myval".teeToInfo(logger) { "hello $it" } },
trapErr { "myval".teeToInfo(logger) { "hello {}" } }
)
outputs.forEach { assertTrue { !it.contains("INFO") } }
}

@Test
fun `should not log with trace level`() {
if (!KTee.debugChanged) KTee.debug = false
val outputs = listOf(
trapErr { "myval".teeToTrace(logger, "hello {}") },
trapErr { "myval".teeToTrace(logger) { "hello $it" } },
trapErr { "myval".teeToTrace(logger) { "hello {}" } }
)
outputs.forEach { assertTrue { it == "" } }
}

@Test
fun `should not log with debug level`() {
if (!KTee.debugChanged) KTee.debug = false
val outputs = listOf(
trapErr { "myval".teeToDebug(logger, "hello {}") },
trapErr { "myval".teeToDebug(logger) { "hello $it" } },
trapErr { "myval".teeToDebug(logger) { "hello {}" } }
)
outputs.forEach { assertTrue { !it.contains("DEBUG") } }
}
}

0 comments on commit dd6833e

Please sign in to comment.