mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
test: rename ExpectMatchContext to ExpectMatch (#25998)
Cleans the last few instances of ExpectMatch that didn't use the new `(ctx, ...)` variant, then deletes the deprecated method and renames `ExpectMatchContext` to drop the `Context` suffix.
This commit is contained in:
@@ -17,9 +17,10 @@ func TestPtytest(t *testing.T) {
|
||||
t.Parallel()
|
||||
t.Run("Echo", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := testutil.Context(t, testutil.WaitMedium)
|
||||
pty := ptytest.New(t)
|
||||
pty.Output().Write([]byte("write"))
|
||||
pty.ExpectMatch("write")
|
||||
pty.ExpectMatch(ctx, "write")
|
||||
pty.WriteLine("read")
|
||||
})
|
||||
|
||||
@@ -38,7 +39,7 @@ func TestPtytest(t *testing.T) {
|
||||
require.Equal(t, "line 2", pty.ReadLine(ctx))
|
||||
require.Equal(t, "line 3", pty.ReadLine(ctx))
|
||||
require.Equal(t, "line 4", pty.ReadLine(ctx))
|
||||
require.Equal(t, "line 5", pty.ExpectMatch("5"))
|
||||
require.Equal(t, "line 5", pty.ExpectMatch(ctx, "5"))
|
||||
})
|
||||
|
||||
// See https://github.com/coder/coder/issues/2122 for the motivation
|
||||
|
||||
@@ -26,9 +26,10 @@ func TestStart(t *testing.T) {
|
||||
t.Parallel()
|
||||
t.Run("Echo", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := testutil.Context(t, testutil.WaitMedium)
|
||||
pty, ps := ptytest.Start(t, pty.Command("echo", "test"))
|
||||
|
||||
pty.ExpectMatch("test")
|
||||
pty.ExpectMatch(ctx, "test")
|
||||
err := ps.Wait()
|
||||
require.NoError(t, err)
|
||||
err = pty.Close()
|
||||
@@ -63,6 +64,7 @@ func TestStart(t *testing.T) {
|
||||
|
||||
t.Run("SSH_TTY", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := testutil.Context(t, testutil.WaitMedium)
|
||||
opts := pty.WithPTYOption(pty.WithSSHRequest(ssh.Pty{
|
||||
Window: ssh.Window{
|
||||
Width: 80,
|
||||
@@ -70,7 +72,7 @@ func TestStart(t *testing.T) {
|
||||
},
|
||||
}))
|
||||
pty, ps := ptytest.Start(t, pty.Command(`/bin/sh`, `-c`, `env | grep SSH_TTY`), opts)
|
||||
pty.ExpectMatch("SSH_TTY=/dev/")
|
||||
pty.ExpectMatch(ctx, "SSH_TTY=/dev/")
|
||||
err := ps.Wait()
|
||||
require.NoError(t, err)
|
||||
err = pty.Close()
|
||||
|
||||
@@ -27,8 +27,9 @@ func TestStart(t *testing.T) {
|
||||
t.Parallel()
|
||||
t.Run("Echo", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := testutil.Context(t, testutil.WaitMedium)
|
||||
ptty, ps := ptytest.Start(t, pty.Command("cmd.exe", "/c", "echo", "test"))
|
||||
ptty.ExpectMatch("test")
|
||||
ptty.ExpectMatch(ctx, "test")
|
||||
err := ps.Wait()
|
||||
require.NoError(t, err)
|
||||
err = ptty.Close()
|
||||
|
||||
Reference in New Issue
Block a user