Skip to content

Commit

Permalink
chore(errors): switch back to Errorf utility functions
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgeMac committed Dec 21, 2022
1 parent 85a7061 commit f3709d5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions internal/server/evaluator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func TestBatchEvaluate_FlagNotFoundExcluded(t *testing.T) {
}
store.On("GetFlag", mock.Anything, "foo").Return(enabledFlag, nil)
store.On("GetFlag", mock.Anything, "bar").Return(disabled, nil)
store.On("GetFlag", mock.Anything, "NotFoundFlag").Return(&flipt.Flag{}, errs.NewErrorf[errs.ErrNotFound]("flag %q", "NotFoundFlag"))
store.On("GetFlag", mock.Anything, "NotFoundFlag").Return(&flipt.Flag{}, errs.ErrNotFoundf("flag %q", "NotFoundFlag"))

store.On("GetEvaluationRules", mock.Anything, "foo").Return([]*storage.EvaluationRule{}, nil)

Expand Down Expand Up @@ -132,7 +132,7 @@ func TestBatchEvaluate_FlagNotFound(t *testing.T) {
}
store.On("GetFlag", mock.Anything, "foo").Return(enabledFlag, nil)
store.On("GetFlag", mock.Anything, "bar").Return(disabled, nil)
store.On("GetFlag", mock.Anything, "NotFoundFlag").Return(&flipt.Flag{}, errs.NewErrorf[errs.ErrNotFound]("flag %q", "NotFoundFlag"))
store.On("GetFlag", mock.Anything, "NotFoundFlag").Return(&flipt.Flag{}, errs.ErrNotFoundf("flag %q", "NotFoundFlag"))

store.On("GetEvaluationRules", mock.Anything, "foo").Return([]*storage.EvaluationRule{}, nil)

Expand Down Expand Up @@ -172,7 +172,7 @@ func TestEvaluate_FlagNotFound(t *testing.T) {
}
)

store.On("GetFlag", mock.Anything, "foo").Return(&flipt.Flag{}, errs.NewErrorf[errs.ErrNotFound]("flag %q", "foo"))
store.On("GetFlag", mock.Anything, "foo").Return(&flipt.Flag{}, errs.ErrNotFoundf("flag %q", "foo"))

resp, err := s.Evaluate(context.TODO(), &flipt.EvaluationRequest{
EntityId: "1",
Expand Down
6 changes: 3 additions & 3 deletions internal/storage/auth/memory/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func WithIDGeneratorFunc(fn func() string) Option {
// string which can be used to retrieve the Authentication again via GetAuthenticationByClientToken.
func (s *Store) CreateAuthentication(_ context.Context, r *auth.CreateAuthenticationRequest) (string, *rpcauth.Authentication, error) {
if r.ExpiresAt != nil && !r.ExpiresAt.IsValid() {
return "", nil, errors.NewErrorf[errors.ErrInvalid]("invalid expiry time: %v", r.ExpiresAt)
return "", nil, errors.ErrInvalidf("invalid expiry time: %v", r.ExpiresAt)
}

var (
Expand Down Expand Up @@ -125,7 +125,7 @@ func (s *Store) GetAuthenticationByClientToken(ctx context.Context, clientToken
authentication, ok := s.byToken[hashedToken]
s.mu.Unlock()
if !ok {
return nil, errors.NewErrorf[errors.ErrNotFound]("getting authentication by token")
return nil, errors.ErrNotFoundf("getting authentication by token")
}

return authentication, nil
Expand All @@ -138,7 +138,7 @@ func (s *Store) GetAuthenticationByID(ctx context.Context, id string) (*rpcauth.
authentication, ok := s.byID[id]
s.mu.Unlock()
if !ok {
return nil, errors.NewErrorf[errors.ErrNotFound]("getting authentication by token")
return nil, errors.ErrNotFoundf("getting authentication by token")
}

return authentication, nil
Expand Down

0 comments on commit f3709d5

Please sign in to comment.