From fa1d14c5132c044140da59cfcbdb326e5c898cb4 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Sun, 30 Apr 2023 14:58:45 +0200 Subject: [PATCH] reference: TestParseAnyReference(): use sub-tests Signed-off-by: Sebastiaan van Stijn --- reference/normalize_test.go | 40 ++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/reference/normalize_test.go b/reference/normalize_test.go index ef3944bef..72b1b92a8 100644 --- a/reference/normalize_test.go +++ b/reference/normalize_test.go @@ -433,26 +433,30 @@ func TestParseAnyReference(t *testing.T) { } for _, tc := range tests { - var ref Reference - var err error - ref, err = ParseAnyReference(tc.Reference) - if err != nil { - t.Fatalf("Error parsing reference %s: %v", tc.Reference, err) - } - if ref.String() != tc.Equivalent { - t.Fatalf("Unexpected string: %s, expected %s", ref.String(), tc.Equivalent) - } - - expected := tc.Expected - if expected == nil { - expected, err = Parse(tc.Equivalent) + tc := tc + t.Run(tc.Reference, func(t *testing.T) { + t.Parallel() + var ref Reference + var err error + ref, err = ParseAnyReference(tc.Reference) if err != nil { - t.Fatalf("Error parsing reference %s: %v", tc.Equivalent, err) + t.Fatalf("Error parsing reference %s: %v", tc.Reference, err) } - } - if !equalReference(ref, expected) { - t.Errorf("Unexpected reference %#v, expected %#v", ref, expected) - } + if ref.String() != tc.Equivalent { + t.Fatalf("Unexpected string: %s, expected %s", ref.String(), tc.Equivalent) + } + + expected := tc.Expected + if expected == nil { + expected, err = Parse(tc.Equivalent) + if err != nil { + t.Fatalf("Error parsing reference %s: %v", tc.Equivalent, err) + } + } + if !equalReference(ref, expected) { + t.Errorf("Unexpected reference %#v, expected %#v", ref, expected) + } + }) } }