Skip to content

Commit a5c7042

Browse files
committed
Rename expect -> console
1 parent 82d715e commit a5c7042

12 files changed

+26
-25
lines changed

cli/clitest/clitest_test.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ package clitest_test
33
import (
44
"testing"
55

6-
"github.com/coder/coder/cli/clitest"
7-
"github.com/coder/coder/coderd/coderdtest"
8-
"github.com/coder/coder/expect"
96
"github.com/stretchr/testify/require"
107
"go.uber.org/goleak"
8+
9+
"github.com/coder/coder/cli/clitest"
10+
"github.com/coder/coder/coderd/coderdtest"
11+
"github.com/coder/coder/console"
1112
)
1213

1314
func TestMain(m *testing.M) {
@@ -20,11 +21,11 @@ func TestCli(t *testing.T) {
2021
client := coderdtest.New(t)
2122
cmd, config := clitest.New(t)
2223
clitest.SetupConfig(t, client, config)
23-
console := expect.NewTestConsole(t, cmd)
24+
testConsole := console.New(t, cmd)
2425
go func() {
2526
err := cmd.Execute()
2627
require.NoError(t, err)
2728
}()
28-
_, err := console.ExpectString("coder")
29+
_, err := testConsole.ExpectString("coder")
2930
require.NoError(t, err)
3031
}

cli/login_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import (
44
"testing"
55

66
"github.com/coder/coder/cli/clitest"
7-
"github.com/coder/coder/expect"
87
"github.com/coder/coder/coderd/coderdtest"
8+
"github.com/coder/coder/console"
99
"github.com/stretchr/testify/require"
1010
)
1111

@@ -26,7 +26,7 @@ func TestLogin(t *testing.T) {
2626
// accurately detect Windows ptys when they are not attached to a process:
2727
// https://github.com/mattn/go-isatty/issues/59
2828
root, _ := clitest.New(t, "login", client.URL.String(), "--force-tty")
29-
console := expect.NewTestConsole(t, root)
29+
console := console.New(t, root)
3030
go func() {
3131
err := root.Execute()
3232
require.NoError(t, err)

cli/projectcreate_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import (
77

88
"github.com/coder/coder/cli/clitest"
99
"github.com/coder/coder/coderd/coderdtest"
10+
"github.com/coder/coder/console"
1011
"github.com/coder/coder/database"
11-
"github.com/coder/coder/expect"
1212
"github.com/coder/coder/provisioner/echo"
1313
"github.com/coder/coder/provisionersdk/proto"
1414
)
@@ -26,7 +26,7 @@ func TestProjectCreate(t *testing.T) {
2626
cmd, root := clitest.New(t, "projects", "create", "--directory", source, "--provisioner", string(database.ProvisionerTypeEcho))
2727
clitest.SetupConfig(t, client, root)
2828
_ = coderdtest.NewProvisionerDaemon(t, client)
29-
console := expect.NewTestConsole(t, cmd)
29+
console := console.New(t, cmd)
3030
closeChan := make(chan struct{})
3131
go func() {
3232
err := cmd.Execute()
@@ -73,7 +73,7 @@ func TestProjectCreate(t *testing.T) {
7373
cmd, root := clitest.New(t, "projects", "create", "--directory", source, "--provisioner", string(database.ProvisionerTypeEcho))
7474
clitest.SetupConfig(t, client, root)
7575
coderdtest.NewProvisionerDaemon(t, client)
76-
console := expect.NewTestConsole(t, cmd)
76+
console := console.New(t, cmd)
7777
closeChan := make(chan struct{})
7878
go func() {
7979
err := cmd.Execute()

cli/workspacecreate_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55

66
"github.com/coder/coder/cli/clitest"
77
"github.com/coder/coder/coderd/coderdtest"
8-
"github.com/coder/coder/expect"
8+
"github.com/coder/coder/console"
99
"github.com/coder/coder/provisioner/echo"
1010
"github.com/coder/coder/provisionersdk/proto"
1111
"github.com/stretchr/testify/require"
@@ -36,7 +36,7 @@ func TestWorkspaceCreate(t *testing.T) {
3636
cmd, root := clitest.New(t, "workspaces", "create", project.Name)
3737
clitest.SetupConfig(t, client, root)
3838

39-
console := expect.NewTestConsole(t, cmd)
39+
console := console.New(t, cmd)
4040
closeChan := make(chan struct{})
4141
go func() {
4242
err := cmd.Execute()

console/console.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package expect
15+
package console
1616

1717
import (
1818
"bufio"
@@ -23,7 +23,7 @@ import (
2323
"os"
2424
"unicode/utf8"
2525

26-
"github.com/coder/coder/expect/pty"
26+
"github.com/coder/coder/console/pty"
2727
)
2828

2929
// Console is an interface to automate input and output for interactive

console/doc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616
// applications. It is unlike expect in that it does not spawn or manage
1717
// process lifecycle. This package only focuses on expecting output and sending
1818
// input through it's psuedoterminal.
19-
package expect
19+
package console

console/expect.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package expect
15+
package console
1616

1717
import (
1818
"bufio"

console/expect_opt.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package expect
15+
package console
1616

1717
import (
1818
"bytes"

console/expect_opt_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package expect_test
15+
package console_test
1616

1717
import (
1818
"bytes"
1919
"testing"
2020

2121
"github.com/stretchr/testify/require"
2222

23-
. "github.com/coder/coder/expect"
23+
. "github.com/coder/coder/console"
2424
)
2525

2626
func TestExpectOptString(t *testing.T) {

console/expect_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package expect_test
15+
package console_test
1616

1717
import (
1818
"bufio"
@@ -26,7 +26,7 @@ import (
2626

2727
"golang.org/x/xerrors"
2828

29-
. "github.com/coder/coder/expect"
29+
. "github.com/coder/coder/console"
3030
)
3131

3232
var (

console/pty/pty_windows.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99

1010
"golang.org/x/sys/windows"
1111

12-
"github.com/coder/coder/expect/conpty"
12+
"github.com/coder/coder/console/conpty"
1313
)
1414

1515
func newPty() (Pty, error) {

console/test_console.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package expect
1+
package console
22

33
import (
44
"bufio"
@@ -16,9 +16,9 @@ var (
1616
stripAnsi = regexp.MustCompile("[\u001B\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[a-zA-Z\\d]*)*)?\u0007)|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))")
1717
)
1818

19-
// NewTestConsole creates a new TTY bound to the command provided.
19+
// New creates a new TTY bound to the command provided.
2020
// All ANSI escape codes are stripped to provide clean output.
21-
func NewTestConsole(t *testing.T, cmd *cobra.Command) *Console {
21+
func New(t *testing.T, cmd *cobra.Command) *Console {
2222
reader, writer := io.Pipe()
2323
scanner := bufio.NewScanner(reader)
2424
t.Cleanup(func() {

0 commit comments

Comments
 (0)