commit e08979683b4f612c7fa4c54159c37f0901a83f33
parent 02e84b5161ed141ac051d10fd3c647dcfc79819b
Author: Brian C. Lane <bcl@brianlane.com>
Date: Sun, 8 Mar 2020 08:21:17 -0700
test: Add test for logDebugf
Diffstat:
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/main_test.go b/main_test.go
@@ -83,10 +83,24 @@ func TestCaptureOutput(t *testing.T) {
func TestLogDebug(t *testing.T) {
// test with default config, no output
+ out := captureOutput(func() {
+ logDebugf("logging debug info")
+ }, false)
+
+ if strings.Contains(out, "logging debug info") {
+ t.Fatal("unexpected debug logging")
+ }
// set global debug to true
- // check output
+ cmdline.Debug = true
+ out = captureOutput(func() {
+ logDebugf("logging debug info")
+ }, false)
+ cmdline.Debug = false
+ if !strings.Contains(out, "logging debug info") {
+ t.Fatal("Missing debug string")
+ }
}
func TestReadConfig(t *testing.T) {