@@ -7,10 +7,10 @@ import (
7
7
8
8
"github.com/coder/coder/cli/clitest"
9
9
"github.com/coder/coder/coderd/coderdtest"
10
- "github.com/coder/coder/console"
11
10
"github.com/coder/coder/database"
12
11
"github.com/coder/coder/provisioner/echo"
13
12
"github.com/coder/coder/provisionersdk/proto"
13
+ "github.com/coder/coder/pty/ptytest"
14
14
)
15
15
16
16
func TestProjectCreate (t * testing.T ) {
@@ -26,7 +26,9 @@ func TestProjectCreate(t *testing.T) {
26
26
cmd ,root := clitest .New (t ,"projects" ,"create" ,"--directory" ,source ,"--provisioner" ,string (database .ProvisionerTypeEcho ))
27
27
clitest .SetupConfig (t ,client ,root )
28
28
_ = coderdtest .NewProvisionerDaemon (t ,client )
29
- console := console .New (t ,cmd )
29
+ pty := ptytest .New (t )
30
+ cmd .SetIn (pty .Input ())
31
+ cmd .SetOut (pty .Output ())
30
32
closeChan := make (chan struct {})
31
33
go func () {
32
34
err := cmd .Execute ()
@@ -43,10 +45,8 @@ func TestProjectCreate(t *testing.T) {
43
45
for i := 0 ;i < len (matches );i += 2 {
44
46
match := matches [i ]
45
47
value := matches [i + 1 ]
46
- _ ,err := console .ExpectString (match )
47
- require .NoError (t ,err )
48
- _ ,err = console .SendLine (value )
49
- require .NoError (t ,err )
48
+ pty .ExpectMatch (match )
49
+ pty .WriteLine (value )
50
50
}
51
51
<- closeChan
52
52
})
@@ -73,7 +73,9 @@ func TestProjectCreate(t *testing.T) {
73
73
cmd ,root := clitest .New (t ,"projects" ,"create" ,"--directory" ,source ,"--provisioner" ,string (database .ProvisionerTypeEcho ))
74
74
clitest .SetupConfig (t ,client ,root )
75
75
coderdtest .NewProvisionerDaemon (t ,client )
76
- cons := console .New (t ,cmd )
76
+ pty := ptytest .New (t )
77
+ cmd .SetIn (pty .Input ())
78
+ cmd .SetOut (pty .Output ())
77
79
closeChan := make (chan struct {})
78
80
go func () {
79
81
err := cmd .Execute ()
@@ -91,10 +93,8 @@ func TestProjectCreate(t *testing.T) {
91
93
for i := 0 ;i < len (matches );i += 2 {
92
94
match := matches [i ]
93
95
value := matches [i + 1 ]
94
- _ ,err := cons .ExpectString (match )
95
- require .NoError (t ,err )
96
- _ ,err = cons .SendLine (value )
97
- require .NoError (t ,err )
96
+ pty .ExpectMatch (match )
97
+ pty .WriteLine (value )
98
98
}
99
99
<- closeChan
100
100
})