Skip to content

refactor: Rename 'expect' package to 'console' #297

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 16, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Rename console -> cons to avoid shadowing
  • Loading branch information
bryphe-coder committed Feb 16, 2022
commit 3604bef031bab881da600d6cf6d43dcf7c13c1e7
4 changes: 2 additions & 2 deletions cli/clitest/clitest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ func TestCli(t *testing.T) {
client := coderdtest.New(t)
cmd, config := clitest.New(t)
clitest.SetupConfig(t, client, config)
testConsole := console.New(t, cmd)
cons := console.New(t, cmd)
go func() {
err := cmd.Execute()
require.NoError(t, err)
}()
_, err := testConsole.ExpectString("coder")
_, err := cons.ExpectString("coder")
require.NoError(t, err)
}
8 changes: 4 additions & 4 deletions cli/login_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func TestLogin(t *testing.T) {
// accurately detect Windows ptys when they are not attached to a process:
// https://github.com/mattn/go-isatty/issues/59
root, _ := clitest.New(t, "login", client.URL.String(), "--force-tty")
console := console.New(t, root)
cons := console.New(t, root)
go func() {
err := root.Execute()
require.NoError(t, err)
Expand All @@ -42,12 +42,12 @@ func TestLogin(t *testing.T) {
for i := 0; i < len(matches); i += 2 {
match := matches[i]
value := matches[i+1]
_, err := console.ExpectString(match)
_, err := cons.ExpectString(match)
require.NoError(t, err)
_, err = console.SendLine(value)
_, err = cons.SendLine(value)
require.NoError(t, err)
}
_, err := console.ExpectString("Welcome to Coder")
_, err := cons.ExpectString("Welcome to Coder")
require.NoError(t, err)
})
}
6 changes: 3 additions & 3 deletions cli/projectcreate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func TestProjectCreate(t *testing.T) {
cmd, root := clitest.New(t, "projects", "create", "--directory", source, "--provisioner", string(database.ProvisionerTypeEcho))
clitest.SetupConfig(t, client, root)
coderdtest.NewProvisionerDaemon(t, client)
console := console.New(t, cmd)
cons := console.New(t, cmd)
closeChan := make(chan struct{})
go func() {
err := cmd.Execute()
Expand All @@ -91,9 +91,9 @@ func TestProjectCreate(t *testing.T) {
for i := 0; i < len(matches); i += 2 {
match := matches[i]
value := matches[i+1]
_, err := console.ExpectString(match)
_, err := cons.ExpectString(match)
require.NoError(t, err)
_, err = console.SendLine(value)
_, err = cons.SendLine(value)
require.NoError(t, err)
}
<-closeChan
Expand Down
8 changes: 4 additions & 4 deletions cli/workspacecreate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestWorkspaceCreate(t *testing.T) {
cmd, root := clitest.New(t, "workspaces", "create", project.Name)
clitest.SetupConfig(t, client, root)

console := console.New(t, cmd)
cons := console.New(t, cmd)
closeChan := make(chan struct{})
go func() {
err := cmd.Execute()
Expand All @@ -51,12 +51,12 @@ func TestWorkspaceCreate(t *testing.T) {
for i := 0; i < len(matches); i += 2 {
match := matches[i]
value := matches[i+1]
_, err := console.ExpectString(match)
_, err := cons.ExpectString(match)
require.NoError(t, err)
_, err = console.SendLine(value)
_, err = cons.SendLine(value)
require.NoError(t, err)
}
_, err := console.ExpectString("Create")
_, err := cons.ExpectString("Create")
require.NoError(t, err)
<-closeChan
})
Expand Down
4 changes: 2 additions & 2 deletions console/console.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,14 @@ func NewConsole(opts ...Opt) (*Console, error) {
closers := []io.Closer{consolePty}
reader := consolePty.Reader()

console := &Console{
cons := &Console{
opts: options,
pty: consolePty,
runeReader: bufio.NewReaderSize(reader, utf8.UTFMax),
closers: closers,
}

return console, nil
return cons, nil
}

// Tty returns an input Tty for accepting input
Expand Down