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,7 +5,6 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
@ -18,6 +17,7 @@ import (
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"golang.zx2c4.com/wireguard/tun"
|
||||
"inet.af/netaddr"
|
||||
"tailscale.com/tstest"
|
||||
"tailscale.com/types/logger"
|
||||
"tailscale.com/wgengine/monitor"
|
||||
)
|
||||
@ -660,13 +660,8 @@ func TestDelRouteIdempotent(t *testing.T) {
|
||||
tun := createTestTUN(t)
|
||||
defer tun.Close()
|
||||
|
||||
var logOutput bytes.Buffer
|
||||
logf := func(format string, args ...interface{}) {
|
||||
fmt.Fprintf(&logOutput, format, args...)
|
||||
if !bytes.HasSuffix(logOutput.Bytes(), []byte("\n")) {
|
||||
logOutput.WriteByte('\n')
|
||||
}
|
||||
}
|
||||
var logOutput tstest.MemLogger
|
||||
logf := logOutput.Logf
|
||||
|
||||
mon, err := monitor.New(logger.Discard)
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user