-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #209 from mmulholla/Add-OC4.9
enable chart verifier to recognize OCP 4.9
- Loading branch information
Showing
2 changed files
with
36 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | ||
} | ||
} |