forked from TrueCloudLab/restic
Ensure Print{,f,ln} use global stdout
This commit is contained in:
parent
f6f240573a
commit
4214b1746e
1 changed files with 28 additions and 0 deletions
28
cmd/restic/global_test.go
Normal file
28
cmd/restic/global_test.go
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
rtest "github.com/restic/restic/internal/test"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Test_PrintFunctionsRespectsGlobalStdout(t *testing.T) {
|
||||||
|
gopts := globalOptions
|
||||||
|
defer func() {
|
||||||
|
globalOptions = gopts
|
||||||
|
}()
|
||||||
|
|
||||||
|
buf := bytes.NewBuffer(nil)
|
||||||
|
globalOptions.stdout = buf
|
||||||
|
|
||||||
|
for _, p := range []func(){
|
||||||
|
func() { Println("message") },
|
||||||
|
func() { Print("message\n") },
|
||||||
|
func() { Printf("mes%s\n", "sage") },
|
||||||
|
} {
|
||||||
|
p()
|
||||||
|
rtest.Equals(t, "message\n", buf.String())
|
||||||
|
buf.Reset()
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue