Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: add regression tests for nil pointer on invalid kubeconfig #2763

Merged
merged 2 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading