Skip to content

Commit

Permalink
Increase racyness in Fetch concurrency test to better stress waitgroup
Browse files Browse the repository at this point in the history
  • Loading branch information
mgnsk committed Dec 22, 2024
1 parent d0e836d commit fa02789
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions internal/backend/backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ func TestConcurrentFetch(t *testing.T) {
}()

<-fetchStarted
errCh <- fmt.Errorf("error fetching value")
go func() {
errCh <- fmt.Errorf("error fetching value")
}()

v, err := b.Fetch("key", func() (string, error) {
return "value", nil
Expand All @@ -185,7 +187,9 @@ func TestConcurrentFetch(t *testing.T) {
}()

<-fetchStarted
valueCh <- "value"
go func() {
valueCh <- "value"
}()

v, err := b.Fetch("key", func() (string, error) {
return "value1", nil
Expand Down

0 comments on commit fa02789

Please sign in to comment.