From 84abb3c190388af0dd76f5f25be12346c838ad95 Mon Sep 17 00:00:00 2001 From: Orpheus Lummis Date: Thu, 27 Apr 2023 12:48:55 -0400 Subject: [PATCH] fix: Better wait in CLI integration test --- tests/integration/cli/utils.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/integration/cli/utils.go b/tests/integration/cli/utils.go index aba0f8dc88..236129fec9 100644 --- a/tests/integration/cli/utils.go +++ b/tests/integration/cli/utils.go @@ -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() @@ -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)