Skip to content

Commit

Permalink
Merge pull request #436 from danielgtaylor/fix-cli-test-race
Browse files Browse the repository at this point in the history
fix: race condition in CLI tests
  • Loading branch information
danielgtaylor authored May 11, 2024
2 parents 992a33d + 2ff5002 commit e089398
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions humacli/humacli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,11 @@ func TestCLICommandWithOptions(t *testing.T) {
func TestCLIShutdown(t *testing.T) {
type Options struct{}

started := false
started := make(chan bool, 1)
stopping := make(chan bool, 1)
cli := humacli.New(func(hooks humacli.Hooks, options *Options) {
hooks.OnStart(func() {
started = true
started <- true
<-stopping
})
hooks.OnStop(func() {
Expand All @@ -221,7 +221,7 @@ func TestCLIShutdown(t *testing.T) {

cli.Root().SetArgs([]string{})
cli.Run()
assert.True(t, started)
assert.True(t, <-started)
}

func TestCLIBadType(t *testing.T) {
Expand Down

0 comments on commit e089398

Please sign in to comment.