Skip to content

Commit

Permalink
Fix tty test and pkg doc
Browse files Browse the repository at this point in the history
  • Loading branch information
cmoog committed May 23, 2020
1 parent 04d7943 commit 76218f0
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
4 changes: 2 additions & 2 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
6 changes: 6 additions & 0 deletions doc.go
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions internal/proto/protocol_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
2 changes: 1 addition & 1 deletion localexec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
5 changes: 4 additions & 1 deletion tty_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 76218f0

Please sign in to comment.