aboutsummaryrefslogtreecommitdiff
path: root/test/segments/kubecontext.spec
diff options
context:
space:
mode:
Diffstat (limited to 'test/segments/kubecontext.spec')
-rwxr-xr-xtest/segments/kubecontext.spec42
1 files changed, 30 insertions, 12 deletions
diff --git a/test/segments/kubecontext.spec b/test/segments/kubecontext.spec
index eaaa2300..63810378 100755
--- a/test/segments/kubecontext.spec
+++ b/test/segments/kubecontext.spec
@@ -18,11 +18,19 @@ function mockKubectl() {
;;
'config')
case "$2" in
- 'current-context')
- echo 'minikube'
- ;;
- 'get-contexts')
- echo '* minikube minikube minikube '
+ 'view')
+ case "$3" in
+ '-o=jsonpath={.current-context}')
+ echo 'minikube'
+ ;;
+ '-o=jsonpath={.contexts'*)
+ echo ''
+ ;;
+ *)
+ echo "Mock value missed"
+ exit 1
+ ;;
+ esac
;;
esac
;;
@@ -36,11 +44,21 @@ function mockKubectlOtherNamespace() {
;;
'config')
case "$2" in
- 'current-context')
- echo 'minikube'
- ;;
- 'get-contexts')
- echo '* minikube minikube minikube kube-system'
+ 'view')
+ case "$3" in
+ # Get Current Context
+ '-o=jsonpath={.current-context}')
+ echo 'minikube'
+ ;;
+ # Get current namespace
+ '-o=jsonpath={.contexts'*)
+ echo 'kube-system'
+ ;;
+ *)
+ echo "Mock value missed"
+ exit 1
+ ;;
+ esac
;;
esac
;;
@@ -51,7 +69,7 @@ function testKubeContext() {
alias kubectl=mockKubectl
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(kubecontext)
- assertEquals "%K{magenta} %F{white%}⎈%f %F{white}minikube/default %k%F{magenta}%f " "$(build_left_prompt)"
+ assertEquals "%K{magenta} %F{white%}⎈ %f%F{white}minikube/default %k%F{magenta}%f " "$(build_left_prompt)"
unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
unalias kubectl
@@ -60,7 +78,7 @@ function testKubeContextOtherNamespace() {
alias kubectl=mockKubectlOtherNamespace
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(kubecontext)
- assertEquals "%K{magenta} %F{white%}⎈%f %F{white}minikube/kube-system %k%F{magenta}%f " "$(build_left_prompt)"
+ assertEquals "%K{magenta} %F{white%}⎈ %f%F{white}minikube/kube-system %k%F{magenta}%f " "$(build_left_prompt)"
unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
unalias kubectl