-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Increase coverage in the openshift package
Adds a couple of small cases for GetOpenshiftClusterVersion. Will need refactoring to get further coverage. Adds cases to the Openshift client tests, where the item already exists. Signed-off-by: Brad P. Crochet <brad@redhat.com>
- Loading branch information
Showing
2 changed files
with
94 additions
and
1 deletion.
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
31 changes: 31 additions & 0 deletions
31
certification/internal/openshift/openshift_version_test.go
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package openshift | ||
|
||
import ( | ||
"os" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
"github.com/redhat-openshift-ecosystem/openshift-preflight/certification/runtime" | ||
) | ||
|
||
var _ = Describe("OpenShift Version", func() { | ||
When("no KUBECONFIG is provided", func() { | ||
It("should return UnknownVersion and an error", func() { | ||
version, err := GetOpenshiftClusterVersion() | ||
Expect(version).To(BeEquivalentTo(runtime.UnknownOpenshiftClusterVersion())) | ||
Expect(err).To(HaveOccurred()) | ||
}) | ||
}) | ||
|
||
When("an invalid KUBECONFIG is passed", func() { | ||
BeforeEach(func() { | ||
os.Setenv("KUBECONFIG", "/bad/kubeconfig") | ||
DeferCleanup(os.Unsetenv, "KUBECONFIG") | ||
}) | ||
It("should return UnkownVersion and an error", func() { | ||
version, err := GetOpenshiftClusterVersion() | ||
Expect(version).To(BeEquivalentTo(runtime.UnknownOpenshiftClusterVersion())) | ||
Expect(err).To(HaveOccurred()) | ||
}) | ||
}) | ||
}) |