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

Add more kubectx tests #111

Merged
merged 3 commits into from Dec 25, 2018

Conversation

@feloy
Copy link
Contributor

commented Dec 24, 2018

No description provided.

Philippe Martin

@googlebot googlebot added the cla: yes label Dec 24, 2018

@ahmetb
Copy link
Owner

left a comment

Mostly good! Thanks a lot.

teardown() {
rm -f $KUBECONFIG
rm -f $XDG_CACHE_HOME/kubectx
rmdir $XDG_CACHE_HOME

This comment has been minimized.

Copy link
@ahmetb

ahmetb Dec 24, 2018

Owner

you can combine all these into one rm -rf $XDG_CACHE_HOME, if you put kubeconfig in that dir, too.


# bats setup function
setup() {
export KUBECONFIG=$(mktemp)

This comment has been minimized.

Copy link
@ahmetb

ahmetb Dec 24, 2018

Owner

I don't understand why you don't do this like

KUBECONFIG="$XDG_CACHE_HOME/kubeconfig"

you're gonna get a random dir every time anyway.

# wrappers around "kubectl config" command

add_cluster() {
kubectl config set-cluster ${1}

This comment has been minimized.

Copy link
@ahmetb

ahmetb Dec 24, 2018

Owner

consider putting "" around all variable references, this prevents splitting by space.

}

@test "create two contexts and switch between contexts" {
add_cluster cluster1

This comment has been minimized.

Copy link
@ahmetb

ahmetb Dec 24, 2018

Owner

I feel like we are gonna repeat this 2-context kubeconfig file a lot. I wish we had a way of automatically getting that.

add_cluster cluster1
add_user user1
add_user user2
add_context user1@cluster1 user1 cluster1

This comment has been minimized.

Copy link
@ahmetb

ahmetb Dec 24, 2018

Owner

I don't think you should modify $KUBECONFIG file in tests.

You can consider doing a cp testdata/kubeconfig "$(mktemp)" for each test, and use that copy. Otherwise we'd be mutating kubeconfig, which can cause problems when we reorder tests. Ideally each test should be idempotent/isolated.

Philippe Martin added 2 commits Dec 25, 2018
Philippe Martin
Philippe Martin
@ahmetb
ahmetb approved these changes Dec 25, 2018
@ahmetb

This comment has been minimized.

Copy link
Owner

commented Dec 25, 2018

Looking good. Thanks! 🙌

@ahmetb ahmetb merged commit acbf324 into ahmetb:master Dec 25, 2018

2 checks passed

cla/google All necessary CLAs are signed
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@feloy feloy deleted the feloy:bats3 branch Dec 25, 2018

ahmetb added a commit that referenced this pull request Jan 28, 2019
v0.6.3
- FIX: Show current context/ns color in interactive (fzf) mode. (#109)
- TEST: Add integration tests for kubectx (#111, #113) and kubens (#105, #117)

Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.