Skip to content

Commit

Permalink
fix: Better wait in CLI integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
orpheuslummis committed Apr 27, 2023
1 parent f0d7fe0 commit 84abb3c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tests/integration/cli/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,17 @@ func runDefraNode(t *testing.T, conf DefraNodeConfig) func() []string {

cfg := config.DefaultConfig()
ctx, cancel := context.WithCancel(context.Background())
go func() {
ready := make(chan struct{})
go func(ready chan struct{}) {
defraCmd := cli.NewDefraCommand(cfg)
defraCmd.RootCmd.SetArgs(
append([]string{"start"}, args...),
)
ready <- struct{}{}
err := defraCmd.Execute(ctx)
assert.NoError(t, err)
}()
}(ready)
<-ready
time.Sleep(1 * time.Second) // time buffer for it to start
cancelAndOutput := func() []string {
cancel()
Expand All @@ -112,7 +115,7 @@ func runDefraCommand(t *testing.T, conf DefraNodeConfig, args []string) (stdout,
"--url", conf.APIURL,
}, args...)
if !contains(args, "--rootdir") {
args = append(args, "--rootdir", t.TempDir())
args = append(args, "--rootdir", conf.rootDir)
}

ctx, cancel := context.WithTimeout(context.Background(), COMMAND_TIMEOUT_SECONDS*time.Second)
Expand Down

0 comments on commit 84abb3c

Please sign in to comment.