Add test for --kubeconfig CLI switch
[#161744765](https://www.pivotaltracker.com/story/show/161744765)
@@ -54,7 +54,8 @@ var _ = Describe("CLI", func() {
Eventually(session.Err).Should(Say(`Starting cf-operator with namespace default`))
})
- Context("when using environment variables", func() {
+ Context("when specifying namespace", func() {
+ Context("via environment variables", func() {
BeforeEach(func() {
os.Setenv("CFO_NAMESPACE", "env-test")
})
@@ -70,7 +71,7 @@ var _ = Describe("CLI", func() {
})
})
- Context("when using switches", func() {
+ Context("via using switches", func() {
It("should start for namespace", func() {
session, err := act("--namespace", "switch-test")
Expect(err).ToNot(HaveOccurred())
@@ -79,6 +80,33 @@ var _ = Describe("CLI", func() {
})
})
+ Context("when specifying kubeconfig", func() {
+ Context("via environment variables", func() {
+ BeforeEach(func() {
+ os.Setenv("KUBECONFIG", "invalid")
+ })
+
+ AfterEach(func() {
+ os.Setenv("KUBECONFIG", "")
+ })
+
+ It("should use specified config", func() {
+ session, err := act()
+ Expect(err).ToNot(HaveOccurred())
+ Eventually(session.Err).Should(Say(`stat invalid: no such file or directory`))
+ })
+ })
+
+ Context("via switches", func() {
+ It("should use specified config", func() {
+ session, err := act("--kubeconfig", "invalid")
+ Expect(err).ToNot(HaveOccurred())
+ Eventually(session.Err).Should(Say(`stat invalid: no such file or directory`))
+ })
+ })
+ })
+ })
+
Describe("version", func() {
It("should show a semantic version number", func() {
session, err := act("version")
