aboutsummaryrefslogtreecommitdiff
path: root/awwan_play_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'awwan_play_test.go')
-rw-r--r--awwan_play_test.go33
1 files changed, 18 insertions, 15 deletions
diff --git a/awwan_play_test.go b/awwan_play_test.go
index 00d407d..4ae0cfc 100644
--- a/awwan_play_test.go
+++ b/awwan_play_test.go
@@ -13,6 +13,7 @@ import (
"path/filepath"
"testing"
+ "git.sr.ht/~shulhan/pakakeh.go/lib/mlog"
"git.sr.ht/~shulhan/pakakeh.go/lib/test"
)
@@ -33,7 +34,8 @@ func TestAwwan_Play_withLocal(t *testing.T) {
type testCase struct {
scriptFile string
lineRange string
- expOutput string
+ expStdout string
+ expStderr string
expError string
}
@@ -60,37 +62,38 @@ func TestAwwan_Play_withLocal(t *testing.T) {
var cases = []testCase{{
scriptFile: filepath.Join(scriptDir, `play.aww`),
lineRange: `1-`,
- expOutput: string(tdata.Output[`play_with_local:output`]),
+ expStdout: string(tdata.Output[`play_with_local:stdout`]),
+ expStderr: string(tdata.Output[`play_with_local:stderr`]),
}, {
scriptFile: filepath.Join(scriptDir, `tmp`),
expError: `NewExecRequest: "testdata/play/awwanssh.test/tmp" is a directory`,
}}
- var (
- ctx = context.Background()
-
- c testCase
- req *ExecRequest
- logw bytes.Buffer
- )
+ var testerr bytes.Buffer
+ var namederr = mlog.NewNamedWriter(`testerr`, &testerr)
+ var testout bytes.Buffer
+ var namedout = mlog.NewNamedWriter(`testout`, &testout)
- for _, c = range cases {
- req, err = NewExecRequest(CommandModePlay, c.scriptFile, c.lineRange)
+ for _, c := range cases {
+ req, err := NewExecRequest(CommandModePlay, c.scriptFile, c.lineRange)
if err != nil {
test.Assert(t, `NewExecRequest: error`, c.expError, err.Error())
continue
}
- logw.Reset()
- req.registerLogWriter(`output`, &logw)
+ testerr.Reset()
+ testout.Reset()
+ req.mlog.RegisterErrorWriter(namederr)
+ req.mlog.RegisterOutputWriter(namedout)
- err = aww.Play(ctx, req)
+ err = aww.Play(context.Background(), req)
if err != nil {
test.Assert(t, `Play: error`, c.expError, err.Error())
continue
}
- test.Assert(t, `Local`, c.expOutput, logw.String())
+ test.Assert(t, `stdout`, c.expStdout, testout.String())
+ test.Assert(t, `stderr`, c.expStderr, testerr.String())
}
}