forked from TrueCloudLab/distribution
reference: TestNormalizedSplitHostname(): use sub-tests
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
fa1d14c513
commit
2819bca991
1 changed files with 15 additions and 16 deletions
|
@ -524,22 +524,21 @@ func TestNormalizedSplitHostname(t *testing.T) {
|
|||
},
|
||||
}
|
||||
for _, tc := range tests {
|
||||
failf := func(format string, v ...interface{}) {
|
||||
t.Logf(strconv.Quote(tc.input)+": "+format, v...)
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
tc := tc
|
||||
t.Run(tc.input, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
named, err := ParseNormalizedNamed(tc.input)
|
||||
if err != nil {
|
||||
failf("error parsing name: %s", err)
|
||||
t.Errorf("error parsing name: %s", err)
|
||||
}
|
||||
domain, name := SplitHostname(named)
|
||||
if domain != tc.domain {
|
||||
failf("unexpected domain: got %q, expected %q", domain, tc.domain)
|
||||
t.Errorf("unexpected domain: got %q, expected %q", domain, tc.domain)
|
||||
}
|
||||
if name != tc.name {
|
||||
failf("unexpected name: got %q, expected %q", name, tc.name)
|
||||
t.Errorf("unexpected name: got %q, expected %q", name, tc.name)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue