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 { for _, tc := range tests {
failf := func(format string, v ...interface{}) { tc := tc
t.Logf(strconv.Quote(tc.input)+": "+format, v...) t.Run(tc.input, func(t *testing.T) {
t.Fail() t.Parallel()
} named, err := ParseNormalizedNamed(tc.input)
if err != nil {
named, err := ParseNormalizedNamed(tc.input) t.Errorf("error parsing name: %s", err)
if err != nil { }
failf("error parsing name: %s", err) domain, name := SplitHostname(named)
} if domain != tc.domain {
domain, name := SplitHostname(named) t.Errorf("unexpected domain: got %q, expected %q", domain, tc.domain)
if domain != tc.domain { }
failf("unexpected domain: got %q, expected %q", domain, tc.domain) if name != tc.name {
} t.Errorf("unexpected name: got %q, expected %q", name, tc.name)
if name != tc.name { }
failf("unexpected name: got %q, expected %q", name, tc.name) })
}
} }
} }