File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change 1
1
package cli_test
2
2
3
3
import (
4
+ "context"
4
5
"testing"
5
6
6
7
"github.com/coder/coder/v2/cli/clitest"
8
+ "github.com/coder/coder/v2/pty/ptytest"
9
+ "github.com/coder/coder/v2/testutil"
10
+ jailcli "github.com/coder/jail/cli"
11
+ "github.com/stretchr/testify/assert"
7
12
)
8
13
9
14
// Actually testing the functionality of coder/jail takes place in the
10
15
// coder/jail repo, since it's a dependency of coder.
11
16
// Here we want to test basically that integrating it as a subcommand doesn't break anything.
12
17
func TestJailSubcommand (t * testing.T ) {
13
- _ , _ = clitest .New (t , "jail" , "--help" )
18
+ inv , _ := clitest .New (t , "jail" , "--help" )
19
+ pty := ptytest .New (t ).Attach (inv )
20
+ ctx , cancelFunc := context .WithTimeout (context .Background (), testutil .WaitShort )
21
+ defer cancelFunc ()
22
+ done := make (chan any )
23
+ go func () {
24
+ errC := inv .WithContext (ctx ).Run ()
25
+ assert .NoError (t , errC )
26
+ close (done )
27
+ }()
28
+
29
+ // Expect the --help output to include the short description.
30
+ // We're simply confirming that `coder jail --help` ran without a runtime error as
31
+ // a good chunk of serpents self validation logic happens at runtime.
32
+ pty .ExpectMatch (jailcli .BaseCommand ().Short )
33
+ cancelFunc ()
34
+ <- done
14
35
}
You can’t perform that action at this time.
0 commit comments