Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(test): Fix require outside of main goroutine #908

Merged
merged 3 commits into from
Feb 9, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions cmd/adsysd/daemon/daemon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"os"
"path/filepath"
"strings"
"sync"
"testing"
"time"

Expand Down Expand Up @@ -308,18 +307,16 @@ func startDaemon(t *testing.T, setupEnv bool, args ...string) (app *daemon.App,
a := daemon.New()
a.SetArgs(args...)

wg := sync.WaitGroup{}
wg.Add(1)
ch := make(chan error)
didrocks marked this conversation as resolved.
Show resolved Hide resolved
go func() {
defer wg.Done()
err := a.Run()
require.NoError(t, err, "Run should exits without any error")
ch <- a.Run()
close(ch)
}()
a.WaitReady()
time.Sleep(50 * time.Millisecond)

return a, func() {
wg.Wait()
require.NoError(t, <-ch, "Run should exit without any errors")
}
}

Expand Down
Loading