Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add debug flag and logging to scan #278

Merged
merged 3 commits into from
Nov 7, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add negative test
filip-debricked committed Nov 7, 2024

Verified

This commit was signed with the committer’s verified signature.
commit c0f0bcbecf5e1cd05418b9b5d2e6bf19b8d370ba
16 changes: 15 additions & 1 deletion internal/debug/debug_test.go
Original file line number Diff line number Diff line change
@@ -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))
}