reference: TestNormalizedSplitHostname(): use sub-tests

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2023-04-30 15:00:51 +02:00
parent fa1d14c513
commit 2819bca991
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C

View file

@ -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()
}
named, err := ParseNormalizedNamed(tc.input)
if err != nil {
failf("error parsing name: %s", err)
}
domain, name := SplitHostname(named)
if domain != tc.domain {
failf("unexpected domain: got %q, expected %q", domain, tc.domain)
}
if name != tc.name {
failf("unexpected name: got %q, expected %q", name, tc.name)
}
tc := tc
t.Run(tc.input, func(t *testing.T) {
t.Parallel()
named, err := ParseNormalizedNamed(tc.input)
if err != nil {
t.Errorf("error parsing name: %s", err)
}
domain, name := SplitHostname(named)
if domain != tc.domain {
t.Errorf("unexpected domain: got %q, expected %q", domain, tc.domain)
}
if name != tc.name {
t.Errorf("unexpected name: got %q, expected %q", name, tc.name)
}
})
}
}