From 5f59b86c78af09769b06146abca125c327d04e58 Mon Sep 17 00:00:00 2001 From: Nicolas Vanheuverzwijn Date: Wed, 14 Oct 2020 13:23:04 -0400 Subject: [PATCH] Update tests/integration/channel/integration_test.go Co-authored-by: Ciprian Hacman --- tests/integration/channel/integration_test.go | 54 +++++++------------ 1 file changed, 19 insertions(+), 35 deletions(-) diff --git a/tests/integration/channel/integration_test.go b/tests/integration/channel/integration_test.go index 01d58178b4..0c25256a90 100644 --- a/tests/integration/channel/integration_test.go +++ b/tests/integration/channel/integration_test.go @@ -392,42 +392,26 @@ func semverString(sv *semver.Version) string { return sv.String() } -// All Image in stable hannel should have a specified upstream image prefix -func TestStableChannel(t *testing.T) { - sourcePath := "../../../channels/stable" - sourceBytes, err := ioutil.ReadFile(sourcePath) - if err != nil { - t.Fatalf("unexpected error reading sourcePath %q: %v", sourcePath, err) - } +// All Images in channel should have a specified upstream image prefix +func TestChannelImages(t *testing.T) { + for _, channel := range []string{"stable", "alpha"} { + t.Run(channel+"-channel", func(t *testing.T) { + sourcePath := "../../../channels/" + channel + sourceBytes, err := ioutil.ReadFile(sourcePath) + if err != nil { + t.Fatalf("unexpected error reading sourcePath %q: %v", sourcePath, err) + } - channel, err := kops.ParseChannel(sourceBytes) - if err != nil { - t.Fatalf("failed to parse channel: %v", err) - } + channel, err := kops.ParseChannel(sourceBytes) + if err != nil { + t.Fatalf("failed to parse channel: %v", err) + } - for _, image := range channel.Spec.Images { - if !channel.HasUpstreamImagePrefix(image.Name) { - t.Errorf("Stable image '%s' has not a recognized prefix. Add the correct prefix to HasUpstreamImagePrefix function", image.Name) - } - } -} - -// All Image in stable hannel should have a specified upstream image prefix -func TestAlphaChannel(t *testing.T) { - sourcePath := "../../../channels/alpha" - sourceBytes, err := ioutil.ReadFile(sourcePath) - if err != nil { - t.Fatalf("unexpected error reading sourcePath %q: %v", sourcePath, err) - } - - channel, err := kops.ParseChannel(sourceBytes) - if err != nil { - t.Fatalf("failed to parse channel: %v", err) - } - - for _, image := range channel.Spec.Images { - if !channel.HasUpstreamImagePrefix(image.Name) { - t.Errorf("Alpha image channel '%s' has not a recognized prefix. Add the correct prefix to HasUpstreamImagePrefix function", image.Name) - } + for _, image := range channel.Spec.Images { + if !channel.HasUpstreamImagePrefix(image.Name) { + t.Errorf("unknown image prefix: %q", image.Name) + } + } + }) } }