Skip to content

fix: update error formatting and test naming #282

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions fieldpath/managers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package fieldpath_test

import (
"fmt"
"reflect"
"testing"

Expand Down Expand Up @@ -155,7 +154,7 @@ func TestManagersEquals(t *testing.T) {
}

for _, test := range tests {
t.Run(fmt.Sprintf(test.name), func(t *testing.T) {
t.Run(test.name, func(t *testing.T) {
want := test.out
got := test.lhs.Difference(test.rhs)
if !reflect.DeepEqual(want, got) {
Expand Down Expand Up @@ -273,7 +272,7 @@ func TestManagersDifference(t *testing.T) {
}

for _, test := range tests {
t.Run(fmt.Sprintf(test.name), func(t *testing.T) {
t.Run(test.name, func(t *testing.T) {
equal := test.lhs.Equals(test.rhs)
if test.equal && !equal {
difference := test.lhs.Difference(test.rhs)
Expand Down
2 changes: 1 addition & 1 deletion internal/cli/operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func (c compare) Execute(w io.Writer) error {
// TODO: I think it'd be neat if we actually emitted a machine-readable
// format.

_, err = fmt.Fprintf(w, got.String())
_, err = fmt.Fprint(w, got.String())

return err
}
4 changes: 2 additions & 2 deletions typed/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func (v *validatingObjectWalker) visitListItems(t *schema.List, list value.List)
func (v *validatingObjectWalker) doList(t *schema.List) (errs ValidationErrors) {
list, err := listValue(v.allocator, v.value)
if err != nil {
return errorf(err.Error())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be "%w" ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is following the same pattern as

return nil, errorf("%v: %v", prefix, err)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, SGTM

return errorf("%v", err)
}

if list == nil {
Expand Down Expand Up @@ -193,7 +193,7 @@ func (v *validatingObjectWalker) visitMapItems(t *schema.Map, m value.Map) (errs
func (v *validatingObjectWalker) doMap(t *schema.Map) (errs ValidationErrors) {
m, err := mapValue(v.allocator, v.value)
if err != nil {
return errorf(err.Error())
return errorf("%v", err)
}
if m == nil {
return nil
Expand Down