Update tests/integration/channel/integration_test.go

Co-authored-by: Ciprian Hacman <ciprianhacman@gmail.com>
This commit is contained in:
Nicolas Vanheuverzwijn 2020-10-14 13:23:04 -04:00 committed by GitHub
parent b0fd89a193
commit 5f59b86c78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 35 deletions

View File

@ -392,42 +392,26 @@ func semverString(sv *semver.Version) string {
return sv.String() return sv.String()
} }
// All Image in stable hannel should have a specified upstream image prefix // All Images in channel should have a specified upstream image prefix
func TestStableChannel(t *testing.T) { func TestChannelImages(t *testing.T) {
sourcePath := "../../../channels/stable" for _, channel := range []string{"stable", "alpha"} {
sourceBytes, err := ioutil.ReadFile(sourcePath) t.Run(channel+"-channel", func(t *testing.T) {
if err != nil { sourcePath := "../../../channels/" + channel
t.Fatalf("unexpected error reading sourcePath %q: %v", sourcePath, err) sourceBytes, err := ioutil.ReadFile(sourcePath)
} if err != nil {
t.Fatalf("unexpected error reading sourcePath %q: %v", sourcePath, err)
}
channel, err := kops.ParseChannel(sourceBytes) channel, err := kops.ParseChannel(sourceBytes)
if err != nil { if err != nil {
t.Fatalf("failed to parse channel: %v", err) t.Fatalf("failed to parse channel: %v", err)
} }
for _, image := range channel.Spec.Images { for _, image := range channel.Spec.Images {
if !channel.HasUpstreamImagePrefix(image.Name) { if !channel.HasUpstreamImagePrefix(image.Name) {
t.Errorf("Stable image '%s' has not a recognized prefix. Add the correct prefix to HasUpstreamImagePrefix function", image.Name) t.Errorf("unknown image prefix: %q", 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)
}
} }
} }