reference: TestParseAnyReference(): use sub-tests
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
fcbddfc6ae
commit
fa1d14c513
1 changed files with 22 additions and 18 deletions
|
@ -433,26 +433,30 @@ func TestParseAnyReference(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range tests {
|
for _, tc := range tests {
|
||||||
var ref Reference
|
tc := tc
|
||||||
var err error
|
t.Run(tc.Reference, func(t *testing.T) {
|
||||||
ref, err = ParseAnyReference(tc.Reference)
|
t.Parallel()
|
||||||
if err != nil {
|
var ref Reference
|
||||||
t.Fatalf("Error parsing reference %s: %v", tc.Reference, err)
|
var err error
|
||||||
}
|
ref, err = ParseAnyReference(tc.Reference)
|
||||||
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 {
|
if err != nil {
|
||||||
t.Fatalf("Error parsing reference %s: %v", tc.Equivalent, err)
|
t.Fatalf("Error parsing reference %s: %v", tc.Reference, err)
|
||||||
}
|
}
|
||||||
}
|
if ref.String() != tc.Equivalent {
|
||||||
if !equalReference(ref, expected) {
|
t.Fatalf("Unexpected string: %s, expected %s", ref.String(), tc.Equivalent)
|
||||||
t.Errorf("Unexpected reference %#v, expected %#v", ref, expected)
|
}
|
||||||
}
|
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue