reference: TestParseRepositoryInfo: use subtests
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
af36dd698f
commit
b50c049fc6
1 changed files with 32 additions and 26 deletions
|
@ -261,35 +261,41 @@ func TestParseRepositoryInfo(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
for _, tcase := range tcases {
|
||||
refStrings := []string{tcase.FamiliarName, tcase.FullName}
|
||||
if tcase.AmbiguousName != "" {
|
||||
refStrings = append(refStrings, tcase.AmbiguousName)
|
||||
for i, tc := range tcases {
|
||||
tc := tc
|
||||
refStrings := []string{tc.FamiliarName, tc.FullName}
|
||||
if tc.AmbiguousName != "" {
|
||||
refStrings = append(refStrings, tc.AmbiguousName)
|
||||
}
|
||||
|
||||
var refs []Named
|
||||
for _, r := range refStrings {
|
||||
t.Run(strconv.Itoa(i)+"/"+r, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
named, err := ParseNormalizedNamed(r)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
t.Fatalf("ref=%s: %v", r, err)
|
||||
}
|
||||
refs = append(refs, named)
|
||||
t.Run("FamiliarName", func(t *testing.T) {
|
||||
if expected, actual := tc.FamiliarName, FamiliarName(named); expected != actual {
|
||||
t.Errorf("Invalid familiar name for %q. Expected %q, got %q", named, expected, actual)
|
||||
}
|
||||
|
||||
for _, r := range refs {
|
||||
if expected, actual := tcase.FamiliarName, FamiliarName(r); expected != actual {
|
||||
t.Fatalf("Invalid normalized reference for %q. Expected %q, got %q", r, expected, actual)
|
||||
})
|
||||
t.Run("FullName", func(t *testing.T) {
|
||||
if expected, actual := tc.FullName, named.String(); expected != actual {
|
||||
t.Errorf("Invalid canonical reference for %q. Expected %q, got %q", named, expected, actual)
|
||||
}
|
||||
if expected, actual := tcase.FullName, r.String(); expected != actual {
|
||||
t.Fatalf("Invalid canonical reference for %q. Expected %q, got %q", r, expected, actual)
|
||||
})
|
||||
t.Run("Domain", func(t *testing.T) {
|
||||
if expected, actual := tc.Domain, Domain(named); expected != actual {
|
||||
t.Errorf("Invalid domain for %q. Expected %q, got %q", named, expected, actual)
|
||||
}
|
||||
if expected, actual := tcase.Domain, Domain(r); expected != actual {
|
||||
t.Fatalf("Invalid domain for %q. Expected %q, got %q", r, expected, actual)
|
||||
})
|
||||
t.Run("RemoteName", func(t *testing.T) {
|
||||
if expected, actual := tc.RemoteName, Path(named); expected != actual {
|
||||
t.Errorf("Invalid remoteName for %q. Expected %q, got %q", named, expected, actual)
|
||||
}
|
||||
if expected, actual := tcase.RemoteName, Path(r); expected != actual {
|
||||
t.Fatalf("Invalid remoteName for %q. Expected %q, got %q", r, expected, actual)
|
||||
}
|
||||
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue