MCPcopy Index your code
hub / github.com/coder/coder / TestStart

Function TestStart

pty/start_windows_test.go:26–69  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

24}
25
26func TestStart(t *testing.T) {
27 t.Parallel()
28 t.Run("Echo", func(t *testing.T) {
29 t.Parallel()
30 ptty, ps := ptytest.Start(t, pty.Command("cmd.exe", "/c", "echo", "test"))
31 ptty.ExpectMatch("test")
32 err := ps.Wait()
33 require.NoError(t, err)
34 err = ptty.Close()
35 require.NoError(t, err)
36 })
37 t.Run("Resize", func(t *testing.T) {
38 t.Parallel()
39 ptty, _ := ptytest.Start(t, pty.Command("cmd.exe"))
40 err := ptty.Resize(100, 50)
41 require.NoError(t, err)
42 err = ptty.Close()
43 require.NoError(t, err)
44 })
45 t.Run("Kill", func(t *testing.T) {
46 t.Parallel()
47 ptty, ps := ptytest.Start(t, pty.Command("cmd.exe"))
48 err := ps.Kill()
49 assert.NoError(t, err)
50 err = ps.Wait()
51 var exitErr *exec.ExitError
52 require.True(t, xerrors.As(err, &exitErr))
53 assert.NotEqual(t, 0, exitErr.ExitCode())
54 err = ptty.Close()
55 require.NoError(t, err)
56 })
57 t.Run("Interrupt", func(t *testing.T) {
58 t.Parallel()
59 ptty, ps := ptytest.Start(t, pty.Command("cmd.exe"))
60 err := ps.Signal(os.Interrupt) // Actually does kill.
61 assert.NoError(t, err)
62 err = ps.Wait()
63 var exitErr *exec.ExitError
64 require.True(t, xerrors.As(err, &exitErr))
65 assert.NotEqual(t, 0, exitErr.ExitCode())
66 err = ptty.Close()
67 require.NoError(t, err)
68 })
69}
70
71// these constants/vars are used by Test_Start_copy
72

Callers

nothing calls this directly

Calls 11

StartFunction · 0.92
CommandFunction · 0.92
AsMethod · 0.80
ExitCodeMethod · 0.80
RunMethod · 0.65
WaitMethod · 0.65
CloseMethod · 0.65
ResizeMethod · 0.65
KillMethod · 0.65
SignalMethod · 0.65
ExpectMatchMethod · 0.45

Tested by

no test coverage detected