Fix up the sub-test style

This commit is contained in:
Wei Huang
2019-12-16 11:28:12 -08:00
parent 3dc521ac04
commit 82afa2bbaf
2 changed files with 49 additions and 39 deletions

View File

@@ -202,18 +202,21 @@ func TestImageLocalityPriority(t *testing.T) {
func TestNormalizedImageName(t *testing.T) {
for _, testCase := range []struct {
Name string
Input string
Output string
}{
{Input: "root", Output: "root:latest"},
{Input: "root:tag", Output: "root:tag"},
{Input: "gcr.io:5000/root", Output: "gcr.io:5000/root:latest"},
{Input: "root@" + getImageFakeDigest("root"), Output: "root@" + getImageFakeDigest("root")},
{Name: "add :latest postfix 1", Input: "root", Output: "root:latest"},
{Name: "add :latest postfix 2", Input: "gcr.io:5000/root", Output: "gcr.io:5000/root:latest"},
{Name: "keep it as is 1", Input: "root:tag", Output: "root:tag"},
{Name: "keep it as is 2", Input: "root@" + getImageFakeDigest("root"), Output: "root@" + getImageFakeDigest("root")},
} {
image := normalizedImageName(testCase.Input)
if image != testCase.Output {
t.Errorf("expected image reference: %q, got %q", testCase.Output, image)
}
t.Run(testCase.Name, func(t *testing.T) {
image := normalizedImageName(testCase.Input)
if image != testCase.Output {
t.Errorf("expected image reference: %q, got %q", testCase.Output, image)
}
})
}
}