Skip to content

Commit

Permalink
Fix this goroutines errors
Browse files Browse the repository at this point in the history
  • Loading branch information
satk0 committed Dec 23, 2024
1 parent ea7d38d commit 7b6ab0a
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions internal/startup_manager/startup_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,19 @@ func TestAppServer(t *testing.T) {
}()

name := net.JoinHostPort("localhost", strconv.Itoa(cfg.Server.Port))
go func(t *testing.T) {
errs := make(chan error, 1)
go func() {
conn, err := net.DialTimeout("tcp", name, timeout)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
errs <- err
if conn != nil {
defer conn.Close()
}
}(t)
}()

err = <-errs
if err != nil {
t.Fatalf("unexpected error: %v", err)
}

err = sm.shutdownServer(ctx)
if err != nil {
Expand Down Expand Up @@ -100,15 +104,19 @@ func TestAppServer(t *testing.T) {

dialer := net.Dialer{Timeout: timeout}
name := net.JoinHostPort("localhost", strconv.Itoa(cfg.Server.Port))
go func(t *testing.T) {

errs := make(chan error, 1)
go func() {
conn, err := tls.DialWithDialer(&dialer, "tcp", name, tlsConfig)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
errs <- err
if conn != nil {
defer conn.Close()
}
}(t)
}()
err = <-errs
if err != nil {
t.Fatalf("unexpected error: %v", err)
}

err = sm.shutdownServer(ctx)
if err != nil {
Expand Down

0 comments on commit 7b6ab0a

Please sign in to comment.