Created
June 17, 2018 14:38
-
-
Save feloy/3e6a41eed2c47ea6e3e93986b42b13c9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
func TestIsVersionOK(t *testing.T) { | |
expectedMajor := "1" | |
expectedMinor := "9" | |
k8s := newTestSimpleK8s() | |
k8s.clientset.Discovery().(*discoveryfake.FakeDiscovery).FakedServerVersion = &version.Info{ | |
Major: expectedMajor, | |
Minor: expectedMinor, | |
} | |
v, err := k8s.isVersion(expectedMajor, expectedMinor) | |
if err != nil { | |
t.Fatal("isVersion should not raise an error") | |
} | |
if v != true { | |
t.Fatal("isVersion should return true") | |
} | |
} | |
func TestIsVersionErrorMajor(t *testing.T) { | |
expectedMajor := "1" | |
expectedMinor := "9" | |
k8s := newTestSimpleK8s() | |
k8s.clientset.Discovery().(*discoveryfake.FakeDiscovery).FakedServerVersion = &version.Info{ | |
Major: "wrong", | |
Minor: "wrong", | |
} | |
_, err := k8s.isVersion(expectedMajor, expectedMinor) | |
if err == nil { | |
t.Fatal("isVersion should raise an error") | |
} | |
expected := "Major version does not match" | |
if err.Error() != expected { | |
t.Fatal("Raised error should be: " + expected) | |
} | |
} | |
func TestIsVersionErrorMinor(t *testing.T) { | |
expectedMajor := "1" | |
expectedMinor := "9" | |
k8s := newTestSimpleK8s() | |
k8s.clientset.Discovery().(*discoveryfake.FakeDiscovery).FakedServerVersion = &version.Info{ | |
Major: expectedMajor, | |
Minor: "wrong", | |
} | |
_, err := k8s.isVersion(expectedMajor, expectedMinor) | |
if err == nil { | |
t.Fatal("isVersion should raise an error") | |
} | |
expected := "Minor version does not match" | |
if err.Error() != expected { | |
t.Fatal("Raised error should be: " + expected) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment