diff options
| author | Shulhan <ms@kilabit.info> | 2023-12-22 02:04:11 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2023-12-22 03:07:52 +0700 |
| commit | c0d336ca456093b2b7c0b585dbe08f62cbc8ca83 (patch) | |
| tree | cb313f0352a91562cc99ad115d62bad1447dc2b9 /awwan_play_test.go | |
| parent | 66a18a789edaa35dfa4446846eeeffabfee0b269 (diff) | |
| download | awwan-c0d336ca456093b2b7c0b585dbe08f62cbc8ca83.tar.xz | |
all: add [context.Context] to Local and Play
Passing context allow the command Local or Play to be cancelled when
running in asynchronous mode, in this case when awwan run with WUI.
Diffstat (limited to 'awwan_play_test.go')
| -rw-r--r-- | awwan_play_test.go | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/awwan_play_test.go b/awwan_play_test.go index f36d021..d0f206e 100644 --- a/awwan_play_test.go +++ b/awwan_play_test.go @@ -7,6 +7,7 @@ package awwan import ( "bytes" + "context" "io/fs" "os" "path/filepath" @@ -66,6 +67,8 @@ func TestAwwan_Play_withLocal(t *testing.T) { }} var ( + ctx = context.Background() + c testCase req *ExecRequest logw bytes.Buffer @@ -81,7 +84,7 @@ func TestAwwan_Play_withLocal(t *testing.T) { logw.Reset() req.registerLogWriter(`output`, &logw) - err = aww.Play(req) + err = aww.Play(ctx, req) if err != nil { test.Assert(t, `Play: error`, c.expError, err.Error()) continue @@ -132,6 +135,8 @@ func TestAwwan_Play_Get(t *testing.T) { }} var ( + ctx = context.Background() + req *ExecRequest c testCaseGetPut fi os.FileInfo @@ -150,7 +155,7 @@ func TestAwwan_Play_Get(t *testing.T) { t.Fatal(err) } - err = aww.Play(req) + err = aww.Play(ctx, req) if err != nil { test.Assert(t, `play error`, c.expError, err.Error()) } @@ -219,6 +224,8 @@ func TestAwwan_Play_Put(t *testing.T) { }} var ( + ctx = context.Background() + req *ExecRequest c testCaseGetPut fi os.FileInfo @@ -237,7 +244,7 @@ func TestAwwan_Play_Put(t *testing.T) { t.Fatal(err) } - err = aww.Play(req) + err = aww.Play(ctx, req) if err != nil { test.Assert(t, `play error`, c.expError, err.Error()) } @@ -310,6 +317,7 @@ func TestAwwan_Play_SudoGet(t *testing.T) { }} var ( + ctx = context.Background() mockin = &mockStdin{} req *ExecRequest @@ -335,7 +343,7 @@ func TestAwwan_Play_SudoGet(t *testing.T) { mockin.buf.WriteString(c.sudoPass) req.stdin = mockin - err = aww.Play(req) + err = aww.Play(ctx, req) if err != nil { test.Assert(t, `play error`, c.expError, err.Error()) } @@ -405,6 +413,8 @@ func TestAwwan_Play_SudoPut(t *testing.T) { }} var ( + ctx = context.Background() + req *ExecRequest c testCaseGetPut fi os.FileInfo @@ -423,7 +433,7 @@ func TestAwwan_Play_SudoPut(t *testing.T) { t.Fatal(err) } - err = aww.Play(req) + err = aww.Play(ctx, req) if err != nil { test.Assert(t, `play error`, c.expError, err.Error()) } |
