-
Notifications
You must be signed in to change notification settings - Fork 0
/
cursor_test.go
46 lines (32 loc) · 1.03 KB
/
cursor_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package surveyexpect
import (
"testing"
"github.com/Netflix/go-expect"
pseudotty "github.com/creack/pty"
"github.com/hinshun/vt10x"
"github.com/stretchr/testify/require"
)
func TestWaitForCursor(t *testing.T) {
t.Parallel()
pty, tty, err := pseudotty.Open()
require.NoError(t, err)
term := vt10x.New(vt10x.WithWriter(tty))
console, err := expect.NewConsole(expect.WithStdin(pty), expect.WithStdout(term), expect.WithCloser(pty, tty))
require.NoError(t, err)
_ = console.Close() //nolint: errcheck
_ = tty.Close() //nolint: errcheck
err = waitForCursor(console)
require.Error(t, err)
}
func TestWaitForCursorTwice(t *testing.T) {
t.Parallel()
pty, tty, err := pseudotty.Open()
require.NoError(t, err)
term := vt10x.New(vt10x.WithWriter(tty))
console, err := expect.NewConsole(expect.WithStdin(pty), expect.WithStdout(term), expect.WithCloser(pty, tty))
require.NoError(t, err)
_ = console.Close() //nolint: errcheck
_ = tty.Close() //nolint: errcheck
err = waitForCursorTwice(console)
require.Error(t, err)
}