-
Notifications
You must be signed in to change notification settings - Fork 377
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
cmd: Update each index instead of just default #588
Merged
k8s-ci-robot
merged 8 commits into
kubernetes-sigs:master
from
chriskim06:index-updates
Apr 13, 2020
+106
−42
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d9f30f8
Update each index instead of just default
chriskim06 de38a18
Fix linting issue
chriskim06 6717fe8
Split into two tests
chriskim06 a4c94da
Code review changes
chriskim06 0e31f9a
Wrap error in search
chriskim06 c674426
Add integration tests
chriskim06 993758c
Code review changes
chriskim06 8a8195d
Code review changes
chriskim06 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,6 +49,52 @@ func TestKrewUpdate(t *testing.T) { | |
} | ||
} | ||
|
||
func TestKrewUpdateMultipleIndexes(t *testing.T) { | ||
skipShort(t) | ||
test, cleanup := NewTest(t) | ||
defer cleanup() | ||
|
||
test = test.WithEnv(constants.EnableMultiIndexSwitch, 1).WithIndex() | ||
// to enable new paths in environment.NewPaths() | ||
os.Setenv(constants.EnableMultiIndexSwitch, "1") | ||
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. Please add a comment like // to enable new paths in environment.NewPaths() |
||
defer os.Unsetenv(constants.EnableMultiIndexSwitch) | ||
|
||
paths := environment.NewPaths(test.Root()) | ||
test.Krew("index", "add", "foo", paths.IndexPath(constants.DefaultIndexName)).RunOrFail() | ||
if err := os.RemoveAll(paths.IndexPluginsPath("foo")); err != nil { | ||
t.Errorf("error removing plugins directory from index: %s", err) | ||
} | ||
test.Krew("update").RunOrFailOutput() | ||
out := string(test.Krew("search").RunOrFailOutput()) | ||
if !strings.Contains(out, "\nctx") { | ||
t.Error("expected plugin ctx in list of plugins") | ||
} | ||
if !strings.Contains(out, "foo/ctx") { | ||
t.Error("expected plugin foo/ctx in list of plugins") | ||
} | ||
} | ||
|
||
func TestKrewUpdateFailedIndex(t *testing.T) { | ||
skipShort(t) | ||
test, cleanup := NewTest(t) | ||
defer cleanup() | ||
|
||
test = test.WithEnv(constants.EnableMultiIndexSwitch, 1).WithIndex() | ||
os.Setenv(constants.EnableMultiIndexSwitch, "1") | ||
defer os.Unsetenv(constants.EnableMultiIndexSwitch) | ||
|
||
paths := environment.NewPaths(test.Root()) | ||
test.TempDir().InitEmptyGitRepo(paths.IndexPath("foo"), "invalid-git") | ||
out, err := test.Krew("update").Run() | ||
if err == nil { | ||
t.Error("expected update to fail") | ||
} | ||
msg := "failed to update the following indexes: foo" | ||
if !strings.Contains(string(out), msg) { | ||
t.Errorf("%q doesn't contain msg=%q", string(out), msg) | ||
} | ||
} | ||
|
||
func TestKrewUpdateListsNewPlugins(t *testing.T) { | ||
skipShort(t) | ||
test, cleanup := NewTest(t) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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’ve realized this if (+counting) isnt necessary since errors.Wrap already handles nil err. Maybe remove?
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.
Sure I can do that. Do you think it will look weird if this ends with the
return errors.Wrapf(...)
?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 it’s fine. I just realized the check is redundant.
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.
Ok I'll remove the check then.