Skip to content

Commit

Permalink
fix race in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kazhuravlev committed Jun 8, 2024
1 parent 1ec1f9f commit fe43b5e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion healthcheck/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"io"
"sync"
"testing"
"time"

Expand Down Expand Up @@ -164,7 +165,12 @@ func TestService(t *testing.T) { //nolint:funlen

func TestServiceMetrics(t *testing.T) { //nolint:paralleltest
res := make(map[string]hc.Status)
setStatus := func(id string, status hc.Status) { res[id] = status }
mu := new(sync.Mutex)
setStatus := func(id string, status hc.Status) {
mu.Lock()
res[id] = status
mu.Unlock()
}

hcInst, err := hc.New(hc.NewOptions(hc.WithSetCheckStatus(setStatus)))
require.NoError(t, err)
Expand Down

0 comments on commit fe43b5e

Please sign in to comment.