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

Commit

Permalink
Refresh all the repos (#470)
Browse files Browse the repository at this point in the history
Currently if config file have a bad repo and some right repos,
monocualr-api don't get charts from repos and no error message to
user. We should try all the repos.
  • Loading branch information
FengyunPan2 authored and prydonius committed Jun 22, 2018
1 parent 03ac29c commit d130146
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/api/data/cache/auto_refresher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ func TestNewRefreshDataError(t *testing.T) {
job := NewRefreshChartsData(chartsImplementation, freshness, "test-run", true)
assert.Equal(t, job.FirstRun(), true, "First run")
err := job.Do()
assert.ExistsErr(t, err, "Error executing refresh")
assert.NoErr(t, err)
}
6 changes: 5 additions & 1 deletion src/api/data/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,11 @@ func (c *cachedCharts) Refresh() error {
for _, repo := range repos {
charts, err := repohelper.GetChartsFromRepoIndexFile(repo)
if err != nil {
return err
log.WithFields(log.Fields{
"repo": repo,
"error": err,
}).Error("error on refresh charts from repo")
continue
}

// 3 - Process elements in index
Expand Down
5 changes: 4 additions & 1 deletion src/api/data/cache/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,10 @@ func TestCachedChartsRefreshErrorPropagation(t *testing.T) {
chImplementation := NewCachedCharts(models.NewMockSession(models.MockDBConfig{}))
models.MockRepos = tt.repos
err := chImplementation.Refresh()
assert.ExistsErr(t, err, tt.name)
assert.NoErr(t, err)
allCharts, err := chImplementation.All()
assert.NoErr(t, err)
assert.True(t, len(allCharts) == 0, "empty charts slice")
})
}
}
Expand Down

0 comments on commit d130146

Please sign in to comment.