Skip to content

Commit

Permalink
Merge pull request #299 from gabriel-samfira/use-errors-wrap
Browse files Browse the repository at this point in the history
Use errors.Wrap() in repositories.go
  • Loading branch information
gabriel-samfira authored Oct 6, 2024
2 parents 6e38e23 + 36b9e9f commit 465b12b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions runner/repositories.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func (r *Runner) UpdateRepository(ctx context.Context, repoID string, param para

poolMgr, err := r.poolManagerCtrl.GetRepoPoolManager(repo)
if err != nil {
return params.Repository{}, fmt.Errorf("failed to get pool manager: %w", err)
return params.Repository{}, errors.Wrap(err, "getting pool manager")
}

repo.PoolManagerStatus = poolMgr.Status()
Expand All @@ -219,7 +219,7 @@ func (r *Runner) CreateRepoPool(ctx context.Context, repoID string, param params

createPoolParams, err := r.appendTagsToCreatePoolParams(param)
if err != nil {
return params.Pool{}, fmt.Errorf("failed to append tags to create pool params: %w", err)
return params.Pool{}, errors.Wrap(err, "appending tags to create pool params")
}

if createPoolParams.RunnerBootstrapTimeout == 0 {
Expand All @@ -233,7 +233,7 @@ func (r *Runner) CreateRepoPool(ctx context.Context, repoID string, param params

pool, err := r.store.CreateEntityPool(ctx, entity, createPoolParams)
if err != nil {
return params.Pool{}, fmt.Errorf("failed to create pool: %w", err)
return params.Pool{}, errors.Wrap(err, "creating pool")
}

return pool, nil
Expand Down
6 changes: 3 additions & 3 deletions runner/repositories_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ func (s *RepoTestSuite) TestUpdateRepositoryPoolMgrFailed() {
_, err := s.Runner.UpdateRepository(s.Fixtures.AdminContext, s.Fixtures.StoreRepos["test-repo-1"].ID, s.Fixtures.UpdateRepoParams)

s.Fixtures.PoolMgrCtrlMock.AssertExpectations(s.T())
s.Require().Equal(fmt.Sprintf("failed to get pool manager: %s", s.Fixtures.ErrMock.Error()), err.Error())
s.Require().Equal(fmt.Sprintf("getting pool manager: %s", s.Fixtures.ErrMock.Error()), err.Error())
}

func (s *RepoTestSuite) TestUpdateRepositoryCreateRepoPoolMgrFailed() {
Expand All @@ -382,7 +382,7 @@ func (s *RepoTestSuite) TestUpdateRepositoryCreateRepoPoolMgrFailed() {
_, err := s.Runner.UpdateRepository(s.Fixtures.AdminContext, s.Fixtures.StoreRepos["test-repo-1"].ID, s.Fixtures.UpdateRepoParams)

s.Fixtures.PoolMgrCtrlMock.AssertExpectations(s.T())
s.Require().Equal(fmt.Sprintf("failed to get pool manager: %s", s.Fixtures.ErrMock.Error()), err.Error())
s.Require().Equal(fmt.Sprintf("getting pool manager: %s", s.Fixtures.ErrMock.Error()), err.Error())
}

func (s *RepoTestSuite) TestCreateRepoPool() {
Expand Down Expand Up @@ -415,7 +415,7 @@ func (s *RepoTestSuite) TestCreateRepoPoolFetchPoolParamsFailed() {

s.Fixtures.PoolMgrMock.AssertExpectations(s.T())
s.Fixtures.PoolMgrCtrlMock.AssertExpectations(s.T())
s.Require().Regexp("failed to append tags to create pool params: no such provider not-existent-provider-name", err.Error())
s.Require().Regexp("appending tags to create pool params: no such provider not-existent-provider-name", err.Error())
}

func (s *RepoTestSuite) TestGetRepoPoolByID() {
Expand Down

0 comments on commit 465b12b

Please sign in to comment.