Skip to content
This repository has been archived by the owner on Jul 12, 2022. It is now read-only.

Commit

Permalink
Update repo fix (#866)
Browse files Browse the repository at this point in the history
  • Loading branch information
henriquemoraeszup committed Feb 22, 2021
1 parent 4c072e2 commit 5116caa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 3 additions & 3 deletions pkg/cmd/update_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,16 @@ func (up updateRepoCmd) runPrompt() CommandRunnerFunc {
return err
}

flagAll := (name == updateOptionAll)
flagAll := name == updateOptionAll

var repoToUpdate []formula.Repo

if flagAll {
repoToUpdate = externalRepos
} else {
for i := range externalRepos {
if repos[i].Name == formula.RepoName(name) {
repoToUpdate = append(repoToUpdate, repos[i])
if externalRepos[i].Name == formula.RepoName(name) {
repoToUpdate = append(repoToUpdate, externalRepos[i])
break
}
}
Expand Down
5 changes: 4 additions & 1 deletion pkg/cmd/update_repo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func TestUpdateRepoRun(t *testing.T) {
in: in{
repo: RepositoryListUpdaterCustomMock{
list: func() (formula.Repos, error) {
return formula.Repos{*repoTest, *repoTest2}, nil
return formula.Repos{*repoTest2, *repoTest}, nil
},
update: func(name formula.RepoName, version formula.RepoVersion) error {
return nil
Expand Down Expand Up @@ -275,6 +275,9 @@ func TestUpdateRepoRun(t *testing.T) {

newReader := strings.NewReader(tt.inputStdin)
newUpdateRepoStdin.SetIn(newReader)
newUpdateRepoStdin.SetArgs([]string{})

newUpdateRepoPrompt.SetArgs([]string{})

if err := newUpdateRepoPrompt.Execute(); (err != nil) != tt.wantErr {
t.Errorf("Prompt command error = %v, wantErr %v", err, tt.wantErr)
Expand Down

0 comments on commit 5116caa

Please sign in to comment.