Skip to content

Commit

Permalink
Merge pull request #2763 from devspace-sh/tests/nil_pointer_regressio…
Browse files Browse the repository at this point in the history
…n_test

tests: add regression tests for nil pointer on invalid kubeconfig
  • Loading branch information
FabianKramm authored Dec 1, 2023
2 parents ebf5fd2 + fefb7d0 commit 79fa51d
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 2 deletions.
22 changes: 22 additions & 0 deletions e2e/tests/pipelines/pipelines.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,4 +417,26 @@ var _ = DevSpaceDescribe("pipelines", func() {
err = devCmd.RunDefault(f)
framework.ExpectNoError(err)
})

ginkgo.It("should not panic on inalid kubeconfig", func() {
tempDir, err := framework.CopyToTempDir("tests/pipelines/testdata/invalid_kubeconfig")
framework.ExpectNoError(err)
defer framework.CleanupTempDir(initialDir, tempDir)

origEnv := os.Getenv("KUBE_CONFIG")
defer os.Setenv("KUBE_CONFIG", origEnv)

os.Setenv("KUBE_CONFIG", "nonexistent.yaml")
newEnv := os.Getenv("KUBE_CONFIG")
framework.ExpectEqual(newEnv, "nonexistent.yaml")

devCmd := &cmd.RunPipelineCmd{
GlobalFlags: &flags.GlobalFlags{
NoWarn: true,
},
Pipeline: "deploy",
}
err = devCmd.RunDefault(f)
framework.ExpectNoError(err)
})
})
6 changes: 6 additions & 0 deletions e2e/tests/pipelines/testdata/invalid_kubeconfig/dep1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: v2beta1
name: dep1

pipelines:
deploy: |-
echo "Hello World"
10 changes: 10 additions & 0 deletions e2e/tests/pipelines/testdata/invalid_kubeconfig/devspace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: v2beta1
name: wait

dependencies:
dep1:
path: dep1.yaml

pipelines:
deploy: |-
run_dependencies --all
4 changes: 2 additions & 2 deletions e2e/tests/ssh/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ var _ = DevSpaceDescribe("ssh", func() {
framework.ExpectNoError(err)
ginkgo.DeferCleanup(framework.CleanupTempDir, initialDir, tempDir)

ns, err := kubeClient.CreateNamespace("ssh")
ns, err := kubeClient.CreateNamespace("ssh-without-service")
framework.ExpectNoError(err)
ginkgo.DeferCleanup(framework.ExpectDeleteNamespace, kubeClient, ns)

Expand Down Expand Up @@ -137,7 +137,7 @@ var _ = DevSpaceDescribe("ssh", func() {
framework.ExpectNoError(err)
ginkgo.DeferCleanup(framework.CleanupTempDir, initialDir, tempDir)

ns, err := kubeClient.CreateNamespace("ssh")
ns, err := kubeClient.CreateNamespace("ssh-with-service")
framework.ExpectNoError(err)
ginkgo.DeferCleanup(framework.ExpectDeleteNamespace, kubeClient, ns)

Expand Down

0 comments on commit 79fa51d

Please sign in to comment.