diff --git a/client_test.go b/client_test.go index 505025f..68b18df 100644 --- a/client_test.go +++ b/client_test.go @@ -43,8 +43,8 @@ func TestRemoteStdin(t *testing.T) { header, body := proto.SplitMessage(msg) - assert.Equal(t, "stdin body", body, []byte(tcase), bytecmp) - assert.Equal(t, "stdin header", header, []byte(`{"type":"stdin"}`), bytecmp) + assert.Equal(t, "stdin body", []byte(tcase), body, bytecmp) + assert.Equal(t, "stdin header", []byte(`{"type":"stdin"}`), header, bytecmp) } } diff --git a/doc.go b/doc.go new file mode 100644 index 0000000..2a2b548 --- /dev/null +++ b/doc.go @@ -0,0 +1,6 @@ +// Package wsep provides server and client interfaces +// for transmitting Linux command execution over a Websocket connection. + +// It provides stdin, stdout, stderr, tty operations, and exit code information. + +package wsep diff --git a/internal/proto/protocol_test.go b/internal/proto/protocol_test.go index f70a877..ab20491 100644 --- a/internal/proto/protocol_test.go +++ b/internal/proto/protocol_test.go @@ -37,7 +37,7 @@ func TestWithHeader(t *testing.T) { assert.Success(t, "read buffer", err) header, body := SplitMessage(msg) - assert.Equal(t, "header is expected value", header, tcase.header, bytecmp) - assert.Equal(t, "body is expected value", body, tcase.body, bytecmp) + assert.Equal(t, "header is expected value", tcase.header, header, bytecmp) + assert.Equal(t, "body is expected value", tcase.body, body, bytecmp) } } diff --git a/localexec_test.go b/localexec_test.go index 77509df..27b9f7c 100644 --- a/localexec_test.go +++ b/localexec_test.go @@ -43,7 +43,7 @@ func testExecer(ctx context.Context, t *testing.T, execer Execer) { stderr, err := ioutil.ReadAll(process.Stderr()) assert.Success(t, "read stderr", err) - assert.Equal(t, "len stderr", 0, len(stderr)) + assert.True(t, "len stderr", len(stderr) == 0) }() err = process.Wait() diff --git a/tty_test.go b/tty_test.go index 94615d9..970407b 100644 --- a/tty_test.go +++ b/tty_test.go @@ -37,8 +37,11 @@ func testTTY(ctx context.Context, t *testing.T, e Execer) { stdout, err := ioutil.ReadAll(process.Stdout()) assert.Success(t, "read stdout", err) + t.Logf("bash tty stdout = %s", stdout) - assert.True(t, `bash "$" prompt found`, strings.HasSuffix(string(stdout), "$ ")) + prompt := string(stdout) + assert.True(t, `bash "$" prompt found`, + strings.HasSuffix(prompt, "$ ") || strings.HasSuffix(prompt, "# ")) }() go func() { wg.Add(1)