github.com/openshift/installer@v1.4.17/pkg/asset/agent/image/releaseimage_test.go (about) 1 package image 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/assert" 7 ) 8 9 func TestReleaseImageList(t *testing.T) { 10 cases := []struct { 11 name string 12 pullSpec string 13 arch string 14 result string 15 }{ 16 { 17 name: "4.10rc", 18 pullSpec: "quay.io/openshift-release-dev/ocp-release:4.10.0-rc.1-x86_64", 19 arch: "x86_64", 20 result: "[{\"openshift_version\":\"4.10\",\"cpu_architecture\":\"x86_64\",\"cpu_architectures\":[\"x86_64\"],\"url\":\"quay.io/openshift-release-dev/ocp-release:4.10.0-rc.1-x86_64\",\"version\":\"4.10.0-rc.1\"}]", 21 }, 22 { 23 name: "pull-spec-includes-port-number", 24 pullSpec: "quay.io:433/openshift-release-dev/ocp-release:4.10.0-rc.1-x86_64", 25 arch: "x86_64", 26 result: "[{\"openshift_version\":\"4.10\",\"cpu_architecture\":\"x86_64\",\"cpu_architectures\":[\"x86_64\"],\"url\":\"quay.io:433/openshift-release-dev/ocp-release:4.10.0-rc.1-x86_64\",\"version\":\"4.10.0-rc.1\"}]", 27 }, 28 { 29 name: "arm", 30 pullSpec: "quay.io/openshift-release-dev/ocp-release:4.10.0-rc.1-aarch64", 31 arch: "aarch64", 32 result: "[{\"openshift_version\":\"4.10\",\"cpu_architecture\":\"aarch64\",\"cpu_architectures\":[\"aarch64\"],\"url\":\"quay.io/openshift-release-dev/ocp-release:4.10.0-rc.1-aarch64\",\"version\":\"4.10.0-rc.1\"}]", 33 }, 34 { 35 name: "4.11ci", 36 pullSpec: "registry.ci.openshift.org/ocp/release:4.11.0-0.ci-2022-05-16-202609", 37 arch: "x86_64", 38 result: "[{\"openshift_version\":\"4.11\",\"cpu_architecture\":\"x86_64\",\"cpu_architectures\":[\"x86_64\"],\"url\":\"registry.ci.openshift.org/ocp/release:4.11.0-0.ci-2022-05-16-202609\",\"version\":\"4.11.0-0.ci-2022-05-16-202609\"}]", 39 }, 40 { 41 name: "CI-ephemeral", 42 pullSpec: "registry.build04.ci.openshift.org/ci-op-m7rfgytz/release@sha256:ebb203f24ee060d61bdb466696a9c20b3841f9929badf9b81fc99cbedc2a679e", 43 arch: "x86_64", 44 result: "[{\"openshift_version\":\"was not built correctly\",\"cpu_architecture\":\"x86_64\",\"cpu_architectures\":[\"x86_64\"],\"url\":\"registry.build04.ci.openshift.org/ci-op-m7rfgytz/release@sha256:ebb203f24ee060d61bdb466696a9c20b3841f9929badf9b81fc99cbedc2a679e\",\"version\":\"was not built correctly\"}]", 45 }, 46 } 47 48 for _, tc := range cases { 49 t.Run(tc.name, func(t *testing.T) { 50 output, err := releaseImageList(tc.pullSpec, tc.arch, []string{tc.arch}) 51 assert.NoError(t, err) 52 if err == nil { 53 assert.Equal(t, tc.result, output) 54 } 55 }) 56 } 57 } 58 59 func TestReleaseImageListErrors(t *testing.T) { 60 cases := []string{ 61 "", 62 "quay.io/openshift-release-dev/ocp-release-4.10", 63 "quay.io/openshift-release-dev/ocp-release:4", 64 } 65 66 for _, tc := range cases { 67 t.Run(tc, func(t *testing.T) { 68 _, err := releaseImageList(tc, "x86_64", []string{"x86_64"}) 69 assert.Error(t, err) 70 }) 71 } 72 }