You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package validator
import (
"testing"
pv "github.com/bufbuild/protovalidate-go"
testv1 "github.com/ennismore/go-buf-connect/v2/internal/test/proto/gen/test/v1""github.com/stretchr/testify/assert"
)
funcTestValidatorError(t*testing.T) {
msg:=&testv1.SmallMessage{
Code: "",
DecimalPlaces: 5,
}
v, _:=pv.New()
err:=v.Validate(msg)
assert.Error(t, err)
assert.Regexp(t, `code: value is required`, err)
assert.Regexp(t, `decimal_places: value must be greater than or equal to 0 and less than or equal to 4`, err)
}
Expected Behavior
To pass. This worked fine with v0.3.2, I expect it to keep working in later releases.
Actual Behavior
Output
=== RUN TestValidatorError
validate_test.go:20:
Error Trace: /home/gary/Projects/go-buf-connect/service/request/validator/validate_test.go:20
Error: An error is expected but got nil.
Test: TestValidatorError
validate_test.go:21:
Error Trace: /home/gary/Projects/go-buf-connect/service/request/validator/validate_test.go:21
Error: Expect "<nil>" to match "code: value is required"
Test: TestValidatorError
validate_test.go:22:
Error Trace: /home/gary/Projects/go-buf-connect/service/request/validator/validate_test.go:22
Error: Expect "<nil>" to match "decimal_places: value must be greater than or equal to 0 and less than or equal to 4"
Test: TestValidatorError
--- FAIL: TestValidatorError (0.00s)
FAIL
FAIL github.com/ennismore/go-buf-connect/v2/service/request/validator 0.004s
FAIL
Thanks for the detailed report, @nomad-software! I am unable to reproduce this bug following your steps using the latest version of this module and protos.
Could you verify for me that the version of the protovalidate protos you are depending on are current (buf mod update) and for good measure bump the version of the remote package in your go.mod (go get -u buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go)?
Hi @rodaine
I've updated everything you suggested and I also had to regenerate the message's proto-buffers too. It's all passing now. Scary that it all just silently failed validation, good job I had the test!
Description
Calling the validate method on a proto message used to work but since v0.3.3 it fails.
Steps to Reproduce
I have a simple message test written like this:
and a unit test like this:
Expected Behavior
To pass. This worked fine with v0.3.2, I expect it to keep working in later releases.
Actual Behavior
Output
Screenshots/Logs
buf.gen.yaml
Environment
Possible Solution
n/a
Additional Context
n/a
The text was updated successfully, but these errors were encountered: