File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change 1
1
package clitest_test
2
2
3
3
import (
4
+ "context"
4
5
"testing"
6
+ "time"
5
7
6
8
"github.com/stretchr/testify/require"
7
9
"go.uber.org/goleak"
@@ -17,16 +19,20 @@ func TestMain(m *testing.M) {
17
19
18
20
func TestCli (t * testing.T ) {
19
21
t .Parallel ()
22
+ ctx , cancelFunc := context .WithTimeout (context .Background (), 5 * time .Second )
23
+ defer cancelFunc ()
20
24
clitest .CreateTemplateVersionSource (t , nil )
21
25
client := coderdtest .New (t , nil )
22
26
cmd , config := clitest .New (t )
23
27
clitest .SetupConfig (t , client , config )
24
28
pty := ptytest .New (t )
25
29
cmd .SetIn (pty .Input ())
26
30
cmd .SetOut (pty .Output ())
31
+ errC := make (chan error )
27
32
go func () {
28
- err := cmd .Execute ()
29
- require .NoError (t , err )
33
+ errC <- cmd .ExecuteContext (ctx )
30
34
}()
31
35
pty .ExpectMatch ("coder" )
36
+ cancelFunc ()
37
+ require .NoError (t , <- errC )
32
38
}
You can’t perform that action at this time.
0 commit comments