tstest: add MemLogger bytes.Buffer wrapper with Logf method
We use it tons of places. Updated three at least in this PR. Another use in next commit. Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:

committed by
Brad Fitzpatrick

parent
30a614f9b9
commit
4c68b7df7c
@ -5,12 +5,13 @@
|
||||
package wgengine
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"tailscale.com/tstest"
|
||||
)
|
||||
|
||||
func TestWatchdog(t *testing.T) {
|
||||
@ -52,11 +53,9 @@ func TestWatchdog(t *testing.T) {
|
||||
wdEngine := e.(*watchdogEngine)
|
||||
wdEngine.maxWait = maxWaitMultiple * 100 * time.Millisecond
|
||||
|
||||
logBuf := new(bytes.Buffer)
|
||||
logBuf := new(tstest.MemLogger)
|
||||
fatalCalled := make(chan struct{})
|
||||
wdEngine.logf = func(format string, args ...interface{}) {
|
||||
fmt.Fprintf(logBuf, format+"\n", args...)
|
||||
}
|
||||
wdEngine.logf = logBuf.Logf
|
||||
wdEngine.fatalf = func(format string, args ...interface{}) {
|
||||
t.Logf("FATAL: %s", fmt.Sprintf(format, args...))
|
||||
fatalCalled <- struct{}{}
|
||||
|
Reference in New Issue
Block a user