Skip to content
This repository has been archived by the owner on Apr 27, 2020. It is now read-only.

Commit

Permalink
Retain current context to remove dependency on minikube (#38)
Browse files Browse the repository at this point in the history
Currently test code depend on minikube environment, so test will
fail if you use extra environment.
This patch removes minikube dependency in test code.
  • Loading branch information
yuanying authored and superbrothers committed Aug 6, 2018
1 parent fb4720d commit 1026bfd
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion test/suite.bats
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
load helper

setup() {
current_context="$(kubectl config current-context)"
# Create a temporary namespace for test
namespace="test-kubernetes-resource-${RANDOM}"
kubectl create ns "$namespace"
# Create a kubeconfig file
kubeconfig_file="$(mktemp)"
kubectl config view --flatten --minify > "$kubeconfig_file"
# Change the current-context to $namespace
kubectl --kubeconfig "$kubeconfig_file" config set-context minikube --namespace "$namespace"
kubectl --kubeconfig "$kubeconfig_file" config set-context ${current_context} --namespace "$namespace"
}

teardown() {
Expand Down

0 comments on commit 1026bfd

Please sign in to comment.