Skip to content
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

Refactor LT/GT into a oneof #33

Merged
merged 8 commits into from
Aug 22, 2023
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
19 changes: 12 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ COPYRIGHT_YEARS := 2023
LICENSE_IGNORE := -e internal/testdata/
# Set to use a different compiler. For example, `GO=go1.18rc1 make test`.
GO ?= go
ARGS ?=
ARGS ?= --strict --strict_message --strict_error
# Set to use a different version of protovalidate-conformance.
# Should be kept in sync with the version referenced in proto/buf.lock and
# 'buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go' in go.mod.
CONFORMANCE_VERSION ?= v0.2.6
CONFORMANCE_VERSION ?= v0.3.1

.PHONY: help
help: ## Describe useful make targets
Expand Down Expand Up @@ -45,11 +45,8 @@ lint-proto: $(BIN)/buf
$(BIN)/buf lint

.PHONY: conformance
conformance: ## Run conformance tests
GOBIN=$(abspath $(BIN)) $(GO) install \
github.com/bufbuild/protovalidate/tools/protovalidate-conformance@$(CONFORMANCE_VERSION)
$(GO) build -o $(BIN)/protovalidate-conformance-go ./internal/cmd/protovalidate-conformance-go
$(BIN)/protovalidate-conformance --strict --strict_message --strict_error $(ARGS) $(BIN)/protovalidate-conformance-go
conformance: $(BIN)/protovalidate-conformance $(BIN)/protovalidate-conformance-go ## Run conformance tests
$(BIN)/protovalidate-conformance $(ARGS) $(BIN)/protovalidate-conformance-go

.PHONY: generate
generate: generate-proto generate-license ## Regenerate code and license headers
Expand Down Expand Up @@ -98,3 +95,11 @@ $(BIN)/license-header: $(BIN) Makefile
$(BIN)/golangci-lint: $(BIN) Makefile
GOBIN=$(abspath $(@D)) $(GO) install \
github.com/golangci/golangci-lint/cmd/golangci-lint@v1.52.2

$(BIN)/protovalidate-conformance: $(BIN) Makefile
GOBIN=$(abspath $(BIN)) $(GO) install \
github.com/bufbuild/protovalidate/tools/protovalidate-conformance@$(CONFORMANCE_VERSION)

$(BIN)/protovalidate-conformance-go: $(BIN) Makefile
GOBIN=$(abspath $(BIN)) $(GO) build -o $(BIN)/protovalidate-conformance-go \
./internal/cmd/protovalidate-conformance-go
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/bufbuild/protovalidate-go
go 1.18

require (
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.31.0-20230802163732-1c33ebd9ecfa.1
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.31.0-20230822184709-ff921ee11715.1
github.com/envoyproxy/protoc-gen-validate v1.0.2
github.com/google/cel-go v0.17.1
github.com/stretchr/testify v1.8.4
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.31.0-20230802163732-1c33ebd9ecfa.1 h1:tdpHgTbmbvEIARu+bixzmleMi14+3imnpoFXz+Qzjp4=
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.31.0-20230802163732-1c33ebd9ecfa.1/go.mod h1:xafc+XIsTxTy76GJQ1TKgvJWsSugFBqMaN27WhUblew=
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.31.0-20230822184709-ff921ee11715.1 h1:r2G+piWhGMS0eEvh//C6qtGDTkQCzafOquDWDve4wuE=
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.31.0-20230822184709-ff921ee11715.1/go.mod h1:xafc+XIsTxTy76GJQ1TKgvJWsSugFBqMaN27WhUblew=
github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230512164433-5d1fd1a340c9 h1:goHVqTbFX3AIo0tzGr14pgfAW2ZfPChKO21Z9MGf/gk=
github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230512164433-5d1fd1a340c9/go.mod h1:pSwJ0fSY5KhvocuWSx4fz3BA8OrA1bQn+K1Eli3BRwM=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 19 additions & 6 deletions legacy/translate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ func TestTranslateFieldOptions(t *testing.T) {
msg: &examplev1.LegacySimple{},
field: "x",
ex: &validate.FieldConstraints{Type: &validate.FieldConstraints_Int32{
Int32: &validate.Int32Rules{Gt: proto.Int32(0)},
Int32: &validate.Int32Rules{
GreaterThan: &validate.Int32Rules_Gt{Gt: 0}},
}},
},
{
Expand Down Expand Up @@ -135,7 +136,11 @@ func TestTranslateFieldOptions(t *testing.T) {
ex: &validate.FieldConstraints{Type: &validate.FieldConstraints_Repeated{
Repeated: &validate.RepeatedRules{Items: &validate.FieldConstraints{
Type: &validate.FieldConstraints_Int32{
Int32: &validate.Int32Rules{Gt: proto.Int32(0)},
Int32: &validate.Int32Rules{
GreaterThan: &validate.Int32Rules_Gt{
Gt: 0,
},
},
},
}},
}},
Expand All @@ -149,7 +154,11 @@ func TestTranslateFieldOptions(t *testing.T) {
String_: &validate.StringRules{MinLen: proto.Uint64(3)},
}},
Values: &validate.FieldConstraints{Type: &validate.FieldConstraints_Int32{
Int32: &validate.Int32Rules{Gt: proto.Int32(0)},
Int32: &validate.Int32Rules{
GreaterThan: &validate.Int32Rules_Gt{
Gt: 0,
},
},
}},
},
}},
Expand Down Expand Up @@ -192,9 +201,13 @@ func TestTranslateFieldOptions(t *testing.T) {
field: "x",
ex: &validate.FieldConstraints{
IgnoreEmpty: true,
Type: &validate.FieldConstraints_Int32{Int32: &validate.Int32Rules{
Gt: proto.Int32(123),
}},
Type: &validate.FieldConstraints_Int32{
Int32: &validate.Int32Rules{
GreaterThan: &validate.Int32Rules_Gt{
Gt: 123,
},
},
},
},
},
}
Expand Down
12 changes: 6 additions & 6 deletions proto/buf.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ deps:
- remote: buf.build
owner: bufbuild
repository: protovalidate
commit: f9bf3460ccf141d68ba17653f5ef85dc
digest: shake256:d763cdb6df6ec05e0859db78e0645a43603d06f0263d4dce59077de8c04c788b3e949c9a08f7769b296c2408d3039631f516cec0f43d0dbc052421c332700769
commit: ff921ee117154e14b8de3b1335a0f257
digest: shake256:a0069b0e821f75d5f1e2074a23856c1e63d5bfabb63286d37aaf64cc2f7854c41a8f0ed6c3cf6de1451e612ec1d1bde589b466c8d892f116905bfbb4e223e6c5
- remote: buf.build
owner: bufbuild
repository: protovalidate-testing
commit: 70b67aedfe1640df8b3fcdfa78933534
digest: shake256:f230308f9c1c8a4192d65be08ec6c525e9fbc113a325bccf1decde22284a974ac0ffdb7354145116bd941ce96fbdad2c85091794df93076660765ece2d6713b3
commit: 9ba6914764d140a2b9666e8b203e309f
digest: shake256:c23ce1466f562c828e181abc00ca47d7f1056bc05fe0048bc365dc4c9f9869d05ccb7688dac777957354083f5258219c242ea81716473c287b86b672580c138b
- remote: buf.build
owner: envoyproxy
repository: protoc-gen-validate
commit: 6607b10f00ed4a3d98f906807131c44a
digest: shake256:acc7b2ededb2f88d296862943a003b157bdb68ec93ed13dcd8566b2d06e47993ea6daf12013b9655658aaf6bbdb141cf65bfe400ce2870f4654b0a5b45e57c09
commit: eac44469a7af47e7839a7f1f3d7ac004
digest: shake256:0feabcde01b6b11e3c75a5e3f807968d5995626546f39c37e5d4205892b3a59cced0ed83b35a2eb9e6dddd3309660ad46b737c9dcd224b425de0a6654ce04417