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

Improve Tester Shutdown #4

Open
ro-tex opened this issue Apr 26, 2022 · 0 comments
Open

Improve Tester Shutdown #4

ro-tex opened this issue Apr 26, 2022 · 0 comments

Comments

@ro-tex
Copy link
Collaborator

ro-tex commented Apr 26, 2022

Note: This also needs to happen in accounts.

f/u This is not very graceful because the goroutines might just be terminated when the test ends without making sure the http server actually shut down. One way to do that gracefully is something like this

tester.externShutdownDone = make(chan error)
go func() {
  tester.externShutdownErr = srv.ListenAndServe()
  close(tester.externShutdownDone)
}()

and then

func (t *Tester) Close() error {
  if err := t.staticSRV.Shutdown(someCtx); err != nil {
    return err
  }
  <-tester.externShutdownDone
  return tester.externShutdownErr
}

Originally posted by @ChrisSchinnerl in #1 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant