Skip to content

Commit

Permalink
Avoid race in progress_test.go (#1081)
Browse files Browse the repository at this point in the history
  • Loading branch information
imjasonh committed Jul 13, 2021
1 parent 03f1bf4 commit 68edb3a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/v1/remote/progress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"net/http/httptest"
"net/url"
"strings"
"sync"
"testing"

"github.com/google/go-cmp/cmp"
Expand Down Expand Up @@ -238,7 +239,10 @@ func TestMultiWrite_Progress_Retry(t *testing.T) {
// Set up a fake registry.
handler := registry.New()
numOfInternalServerErrors := 0
var mu sync.Mutex
registryThatFailsOnFirstUpload := http.HandlerFunc(func(responseWriter http.ResponseWriter, request *http.Request) {
mu.Lock()
defer mu.Unlock()
if strings.Contains(request.URL.Path, "/manifests/") && numOfInternalServerErrors < 1 {
numOfInternalServerErrors++
responseWriter.WriteHeader(500)
Expand Down

0 comments on commit 68edb3a

Please sign in to comment.