reference, registry: fix loop variable captured by func literal (govet)

reference/normalize_test.go:274:40: loopclosure: loop variable r captured by func literal (govet)
                                   named, err := ParseNormalizedNamed(r)
                                                                      ^
    reference/normalize_test.go:276:29: loopclosure: loop variable r captured by func literal (govet)
                        t.Fatalf("ref=%s: %v", r, err)
                                               ^
    registry/api/errcode/errors_test.go:45:7: loopclosure: loop variable ec captured by func literal (govet)
                if ec != desc.Code {
                   ^
    registry/api/errcode/errors_test.go:46:66: loopclosure: loop variable ec captured by func literal (govet)
                    t.Fatalf("error code in descriptor isn't correct, %q != %q", ec, desc.Code)
                                                                                 ^
    registry/api/errcode/errors_test.go:49:23: loopclosure: loop variable desc captured by func literal (govet)
                if idToDescriptors[desc.Value].Code != ec {
                                   ^
    registry/api/errcode/errors_test.go:50:80: loopclosure: loop variable desc captured by func literal (govet)
                    t.Fatalf("error code in idToDesc isn't correct, %q != %q", idToDescriptors[desc.Value].Code, ec)
                                                                                               ^
    registry/api/errcode/errors_test.go:53:7: loopclosure: loop variable ec captured by func literal (govet)
                if ec.Message() != desc.Message {
                   ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2023-05-09 15:29:12 +02:00
parent c9b844e533
commit 4052d269f5
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C
2 changed files with 4 additions and 1 deletions

View file

@ -269,6 +269,7 @@ func TestParseRepositoryInfo(t *testing.T) {
}
for _, r := range refStrings {
r := r
t.Run(strconv.Itoa(i)+"/"+r, func(t *testing.T) {
t.Parallel()
named, err := ParseNormalizedNamed(r)

View file

@ -39,9 +39,11 @@ func TestErrorCodes(t *testing.T) {
t.Fatal("errors aren't loaded!")
}
for ec, desc := range errorCodeToDescriptors {
for ec := range errorCodeToDescriptors {
ec := ec
t.Run(ec.String(), func(t *testing.T) {
t.Parallel()
desc := errorCodeToDescriptors[ec]
if ec != desc.Code {
t.Fatalf("error code in descriptor isn't correct, %q != %q", ec, desc.Code)
}