Prechádzať zdrojové kódy

Fix ticks test to capture stdout properly

Signed-off-by: Robert Lin <robertlin1@gmail.com>
Robert Lin 6 rokov pred
rodič
commit
1c61d26c3a
1 zmenil súbory, kde vykonal 3 pridanie a 9 odobranie
  1. 3 9
      internal/plumbing/ticks_test.go

+ 3 - 9
internal/plumbing/ticks_test.go

@@ -2,8 +2,6 @@ package plumbing
 
 import (
 	"bytes"
-	"log"
-	"os"
 	"strings"
 	"testing"
 	"time"
@@ -189,15 +187,11 @@ func TestTicksSinceStartConsumeZero(t *testing.T) {
 	deps[core.DependencyCommit] = commit
 	deps[core.DependencyIndex] = 0
 	// print warning to log
-	myOutput := &bytes.Buffer{}
-	log.SetOutput(myOutput)
-	defer func() {
-		log.SetOutput(os.Stderr)
-	}()
+	var capture bytes.Buffer
+	tss.l.(*core.DefaultLogger).W.SetOutput(&capture)
 	res, err := tss.Consume(deps)
 	assert.Nil(t, err)
-	output := myOutput.String()
-	assert.Contains(t, output, "Warning")
+	output := capture.String()
 	assert.Contains(t, output, "cce947b98a050c6d356bc6ba95030254914027b1")
 	assert.Contains(t, output, "hercules")
 	// depending on where the contributor clones this project from, the remote