From c0f0bcbecf5e1cd05418b9b5d2e6bf19b8d370ba Mon Sep 17 00:00:00 2001 From: filip Date: Thu, 7 Nov 2024 15:43:28 +0100 Subject: [PATCH] Add negative test --- internal/debug/debug_test.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/internal/debug/debug_test.go b/internal/debug/debug_test.go index bc2b1fc5..ddb7818b 100644 --- a/internal/debug/debug_test.go +++ b/internal/debug/debug_test.go @@ -8,7 +8,7 @@ import ( "github.com/stretchr/testify/assert" ) -func TestPrint(t *testing.T) { +func TestLog(t *testing.T) { rescueStderr := os.Stderr r, w, _ := os.Pipe() os.Stderr = w @@ -22,3 +22,17 @@ func TestPrint(t *testing.T) { assert.Contains(t, string(output), "DEBUG: ") assert.Contains(t, string(output), "hello\n") } + +func TestLogDebugDisabled(t *testing.T) { + rescueStderr := os.Stderr + r, w, _ := os.Pipe() + os.Stderr = w + + Log("hello", false) + + _ = w.Close() + output, _ := io.ReadAll(r) + os.Stderr = rescueStderr + + assert.Empty(t, string(output)) +}