Skip to content

Commit

Permalink
Merge pull request #209 from mmulholla/Add-OC4.9
Browse files Browse the repository at this point in the history
enable chart verifier to recognize OCP 4.9
  • Loading branch information
Allen Bai authored Oct 21, 2021
2 parents 5d3e263 + d740dea commit d556973
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 18 deletions.
1 change: 1 addition & 0 deletions pkg/tool/oc.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const osVersionKey = "serverVersion"

// Based on https://access.redhat.com/solutions/4870701
var kubeOpenShiftVersionMap map[string]string = map[string]string{
"1.22": "4.9.0",
"1.21": "4.8.0",
"1.20": "4.7.0",
"1.19": "4.6.0",
Expand Down
53 changes: 35 additions & 18 deletions pkg/tool/oc_test.go
Original file line number Diff line number Diff line change
@@ -1,41 +1,58 @@
package tool

import "testing"
import (
"fmt"
"testing"
)

type TestData struct {
getVersionOut string
OCVersion string
}

type fakeProcessExecutor struct {
Output string
}

var output47 = `
var output120 = `
serverVersion:
major: "1"
minor: "20"
`
var output121 = `
serverVersion:
major: "1"
minor: "21"
`
var output122 = `
serverVersion:
major: "1"
minor: "22"
`

var testsData []TestData

func (p fakeProcessExecutor) RunProcessAndCaptureOutput(executable string, execArgs ...interface{}) (string, error) {
return p.Output, nil
}

func TestOcVersion47(t *testing.T) {
fp := fakeProcessExecutor{Output: output47}
oc := NewOc(fp)
version, _ := oc.GetVersion()
if version != "4.7.0" {
t.Error("Version mismatch", version)
func TestOCVersions(t *testing.T) {

testsData = append(testsData, TestData{getVersionOut: output120, OCVersion: "4.7.0"})
testsData = append(testsData, TestData{getVersionOut: output121, OCVersion: "4.8.0"})
testsData = append(testsData, TestData{getVersionOut: output122, OCVersion: "4.9.0"})

for _, testdata := range testsData {
t.Logf("Check for OC %s", testdata.OCVersion)
checkOcVersion(testdata.getVersionOut, testdata.OCVersion, t)
}
}

var output48 = `
serverVersion:
major: "1"
minor: "21"
`

func TestOcVersion48(t *testing.T) {
fp := fakeProcessExecutor{Output: output48}
func checkOcVersion(kubeVersion string, expectedOCVersion string, t *testing.T) {
fp := fakeProcessExecutor{Output: kubeVersion}
oc := NewOc(fp)
version, _ := oc.GetVersion()
if version != "4.8.0" {
t.Error("Version mismatch", version)
if version != expectedOCVersion {
t.Error(fmt.Sprintf("Version mismatch expected: %s, got: %s", expectedOCVersion, version))
}
}

0 comments on commit d556973

Please sign in to comment.