@@ -4,7 +4,6 @@ import org.slf4j.Logger
44import org.slf4j.LoggerFactory
55import kotlin.test.Test
66import kotlin.test.assertEquals
7- import kotlin.test.assertFailsWith
87import kotlin.test.assertTrue
98
109class KTeeTest {
@@ -65,60 +64,4 @@ class KTeeTest {
6564 outputs.forEach { assertTrue { it.endsWith(" hello myval" + System .lineSeparator()) } }
6665 }
6766
68- @Test
69- fun `should throw IllegalStateException` () {
70- assertFailsWith<IllegalStateException > {
71- KTee .debug = false ; KTee .debug = false }
72- }
73-
74- @Test
75- fun `should not write to stdout` () {
76- if (! KTee .debugChanged) KTee .debug = false
77- assertEquals(" " , trapOut { " myval" .tee() })
78- }
79-
80- @Test
81- fun `should not evaluate lambda or write to stdout` () {
82- if (! KTee .debugChanged) KTee .debug = false
83- assertEquals(" " , trapOut { " myval" .tee { v -> " value is $v " } })
84- }
85-
86- @Test
87- fun `should not write to logger` () {
88- if (! KTee .debugChanged) KTee .debug = false
89- assertTrue(trapErr { " myval" .teeToInfo(logger) } == " " )
90- }
91-
92- @Test
93- fun `should not log with info level` () {
94- if (! KTee .debugChanged) KTee .debug = false
95- val outputs = listOf (
96- trapErr { " myval" .teeToInfo(logger, " hello {}" ) },
97- trapErr { " myval" .teeToInfo(logger) { " hello $it " } },
98- trapErr { " myval" .teeToInfo(logger) { " hello {}" } }
99- )
100- outputs.forEach { assertTrue { ! it.contains(" INFO" ) } }
101- }
102-
103- @Test
104- fun `should not log with trace level` () {
105- if (! KTee .debugChanged) KTee .debug = false
106- val outputs = listOf (
107- trapErr { " myval" .teeToTrace(logger, " hello {}" ) },
108- trapErr { " myval" .teeToTrace(logger) { " hello $it " } },
109- trapErr { " myval" .teeToTrace(logger) { " hello {}" } }
110- )
111- outputs.forEach { assertTrue { it == " " } }
112- }
113-
114- @Test
115- fun `should not log with debug level` () {
116- if (! KTee .debugChanged) KTee .debug = false
117- val outputs = listOf (
118- trapErr { " myval" .teeToDebug(logger, " hello {}" ) },
119- trapErr { " myval" .teeToDebug(logger) { " hello $it " } },
120- trapErr { " myval" .teeToDebug(logger) { " hello {}" } }
121- )
122- outputs.forEach { assertTrue { ! it.contains(" DEBUG" ) } }
123- }
12467}
0 commit comments