Skip to content

Commit

Permalink
addressing comments from eric #2
Browse files Browse the repository at this point in the history
  • Loading branch information
gehrkefc committed Sep 13, 2024
1 parent be0c0a3 commit ed8bdb6
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 7 deletions.
3 changes: 2 additions & 1 deletion pkg/stores/partition/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package partition

import (
"context"
"errors"
"fmt"
"os"
"reflect"
Expand Down Expand Up @@ -389,7 +390,7 @@ func ToAPIEvent(apiOp *types.APIRequest, schema *types.APISchema, event watch.Ev

if event.Type == watch.Error {
status, _ := event.Object.(*metav1.Status)
apiEvent.Error = fmt.Errorf("%s", status.Message)
apiEvent.Error = errors.New(status.Message)
return apiEvent
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/stores/proxy/proxy_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ func (s *Store) Update(apiOp *types.APIRequest, schema *types.APISchema, params

resourceVersion := input.String("metadata", "resourceVersion")
if resourceVersion == "" {
return nil, nil, fmt.Errorf(errResourceVersionRequired)
return nil, nil, errors.New(errResourceVersionRequired)
}

gvk := attributes.GVK(schema)
Expand Down
9 changes: 7 additions & 2 deletions pkg/stores/proxy/proxy_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ func TestUpdate(t *testing.T) {
expected: expected{
value: nil,
warning: nil,
err: fmt.Errorf(errResourceVersionRequired),
err: errors.New(errResourceVersionRequired),
},
},
{
Expand Down Expand Up @@ -834,7 +834,12 @@ func TestUpdate(t *testing.T) {

assert.Equal(t, tt.expected.value, value)
assert.Equal(t, tt.expected.warning, warning)
assert.Equal(t, tt.expected.err, err)

if tt.expected.err != nil {
assert.Equal(t, tt.expected.err.Error(), err.Error())
} else {
assert.NoError(t, err)
}
})
}
}
2 changes: 1 addition & 1 deletion pkg/stores/sqlproxy/proxy_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ func (s *Store) Update(apiOp *types.APIRequest, schema *types.APISchema, params

resourceVersion := input.String("metadata", "resourceVersion")
if resourceVersion == "" {
return nil, nil, fmt.Errorf(errResourceVersionRequired)
return nil, nil, errors.New(errResourceVersionRequired)
}

gvk := attributes.GVK(schema)
Expand Down
9 changes: 7 additions & 2 deletions pkg/stores/sqlproxy/proxy_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1371,7 +1371,7 @@ func TestUpdate(t *testing.T) {
expected: expected{
value: nil,
warning: nil,
err: fmt.Errorf(errResourceVersionRequired),
err: errors.New(errResourceVersionRequired),
},
},
{
Expand Down Expand Up @@ -1449,7 +1449,12 @@ func TestUpdate(t *testing.T) {

assert.Equal(t, tt.expected.value, value)
assert.Equal(t, tt.expected.warning, warning)
assert.Equal(t, tt.expected.err, err)

if tt.expected.err != nil {
assert.Equal(t, tt.expected.err.Error(), err.Error())
} else {
assert.NoError(t, err)
}
})
}
}

0 comments on commit ed8bdb6

Please sign in to comment.