From 872f8b00ccc1f8b80cb88f6decc2ecfe68cb6818 Mon Sep 17 00:00:00 2001 From: Yann Hamon Date: Sat, 10 May 2025 20:23:44 +0200 Subject: [PATCH] fix tests, minor changes in output --- pkg/validator/validator.go | 2 +- pkg/validator/validator_test.go | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/validator/validator.go b/pkg/validator/validator.go index ef18092..9e8ae0d 100644 --- a/pkg/validator/validator.go +++ b/pkg/validator/validator.go @@ -204,7 +204,7 @@ func (val *v) ValidateResource(res resource.Resource) Result { } validationErrors = append(validationErrors, ValidationError{ Path: path, - Msg: ve.LocalizedError(message.NewPrinter(language.English)), + Msg: ve.ErrorKind.LocalizedString(message.NewPrinter(language.English)), }) } diff --git a/pkg/validator/validator_test.go b/pkg/validator/validator_test.go index aa86951..4e50525 100644 --- a/pkg/validator/validator_test.go +++ b/pkg/validator/validator_test.go @@ -106,7 +106,7 @@ lastName: bar []ValidationError{ { Path: "/firstName", - Msg: "expected number, but got string", + Msg: "got string, want number", }, }, }, @@ -145,7 +145,7 @@ firstName: foo []ValidationError{ { Path: "", - Msg: "missing properties: 'lastName'", + Msg: "missing property 'lastName'", }, }, }, @@ -447,8 +447,8 @@ age: not a number }`) expectedErrors := []ValidationError{ - {Path: "", Msg: "missing properties: 'lastName'"}, - {Path: "/age", Msg: "expected integer, but got string"}, + {Path: "", Msg: "missing property 'lastName'"}, + {Path: "/age", Msg: "got string, want integer"}, } val := v{ @@ -523,7 +523,7 @@ firstName: foo expectedStatuses := []Status{Valid, Invalid} expectedValidationErrors := []ValidationError{ - {Path: "", Msg: "missing properties: 'lastName'"}, + {Path: "", Msg: "missing property 'lastName'"}, } if !reflect.DeepEqual(expectedStatuses, gotStatuses) { t.Errorf("Expected %+v, got %+v", expectedStatuses, gotStatuses)