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
Merged

Add more kubectx tests #111

merged 3 commits into from
Dec 25, 2018

Conversation

feloy
Copy link
Contributor

@feloy feloy commented Dec 24, 2018

No description provided.

Copy link
Owner

@ahmetb ahmetb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly good! Thanks a lot.

test/common.bash Outdated
teardown() {
rm -f $KUBECONFIG
rm -f $XDG_CACHE_HOME/kubectx
rmdir $XDG_CACHE_HOME
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

test/common.bash Outdated

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

test/common.bash Outdated
# wrappers around "kubectl config" command

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

}

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@ahmetb
Copy link
Owner

ahmetb commented Dec 25, 2018

Looking good. Thanks! 🙌

@ahmetb ahmetb merged commit acbf324 into ahmetb:master Dec 25, 2018
@feloy feloy deleted the bats3 branch December 25, 2018 20:51
ahmetb added a commit that referenced this pull request Jan 28, 2019
- 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
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants