-
Notifications
You must be signed in to change notification settings - Fork 1.3k
add unset flag #187
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 unset flag #187
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -239,3 +239,26 @@ load common | |
[ "$status" -eq 0 ] | ||
[[ "$output" = "user2@cluster1" ]] | ||
} | ||
|
||
@test "no selected context" { | ||
use_config config1 | ||
|
||
run ${COMMAND} -c | ||
echo "$output" | ||
[ "$status" -eq 1 ] | ||
[[ "$output" = "error: current-context is not set" ]] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this message is coming from maybe let's just do this:
tbh you can just omit this test in this patch. it's not about |
||
|
||
} | ||
|
||
@test "unset selected context" { | ||
use_config config3 | ||
|
||
run ${COMMAND} -u | ||
echo "$output" | ||
[ "$status" -eq 0 ] | ||
|
||
run ${COMMAND} -c | ||
echo "$output" | ||
[ "$status" -eq 1 ] | ||
[[ "$output" = "error: current-context is not set" ]] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto let's not check the error message equality here, it's coming from kubectl, and may change. |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# config with two contexts and a selected default | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need a new file? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah good question, I didn't want to make existing / future tests more complicated by overloading fixtures but happy to merge into There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What I meant was that you can use an existing testdata file, and first set a context in test code, and then unset it. This way you wouldn't be modifying the existing testdata file. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah that makes more sense! |
||
|
||
apiVersion: v1 | ||
clusters: | ||
- cluster: | ||
server: "" | ||
name: cluster1 | ||
contexts: | ||
- context: | ||
cluster: cluster1 | ||
user: user1 | ||
name: user1@cluster1 | ||
- context: | ||
cluster: cluster1 | ||
user: user2 | ||
name: user2@cluster1 | ||
current-context: "user1@cluster1" | ||
kind: Config | ||
preferences: {} | ||
users: | ||
- name: user1 | ||
user: {} | ||
- name: user2 | ||
user: {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
default -> current
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this message is not really necessary, as kubectl will always print
Property "current-context" unset.
even though the file is empty.So the "progress" message is not necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just going for consistency. Eg.