-
Notifications
You must be signed in to change notification settings - Fork 7
Move unit tests to local protos #288
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
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Generated by buf. DO NOT EDIT. | ||
version: v2 | ||
deps: | ||
- name: buf.build/bufbuild/protovalidate | ||
commit: 0409229c37804d6187ee0806eb4eebce | ||
digest: b5:795db9d3a6e066dc61d99ac651fa7f136171869abe2211ca272dd84aada7bc4583b9508249fa5b61300a5b1fe8b6dbf6edbc088aa0345d1ccb9fff705e3d48e9 | ||
- name: buf.build/bufbuild/protovalidate-testing | ||
commit: 5acbe1f3c8f24ced9466b9ccccad4cb0 | ||
digest: b5:5e9d54d19ce3d9d368f4b1b5ee4f20094d1c33d0f2dca19536339335c2e70d5ffedbd4fa28e290b59ecae0671c9d2dc20b6b8ebba5a9ac76cbf5f9d2af655ef4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
version: v2 | ||
modules: | ||
- path: proto | ||
deps: | ||
- buf.build/bufbuild/protovalidate | ||
- buf.build/bufbuild/protovalidate-testing | ||
lint: | ||
use: | ||
- STANDARD | ||
ignore_only: | ||
PROTOVALIDATE: | ||
- proto/tests/example/v1/validations.proto | ||
breaking: | ||
use: | ||
- FILE |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// Copyright 2023-2025 Buf Technologies, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
syntax = "proto3"; | ||
|
||
package tests.example.v1; | ||
|
||
import "buf/validate/validate.proto"; | ||
import "google/protobuf/timestamp.proto"; | ||
|
||
message DoubleFinite { | ||
double val = 1 [(buf.validate.field).double.finite = true]; | ||
} | ||
|
||
message SFixed64ExLTGT { | ||
sfixed64 val = 1 [(buf.validate.field).sfixed64 = { | ||
lt: 0 | ||
gt: 10 | ||
}]; | ||
} | ||
|
||
message TestOneofMsg { | ||
bool val = 1 [(buf.validate.field).bool.const = true]; | ||
} | ||
|
||
message Oneof { | ||
oneof o { | ||
string x = 1 [(buf.validate.field).string.prefix = "foo"]; | ||
int32 y = 2 [(buf.validate.field).int32.gt = 0]; | ||
TestOneofMsg z = 3; | ||
} | ||
} | ||
|
||
message TimestampGTNow { | ||
google.protobuf.Timestamp val = 1 [(buf.validate.field).timestamp.gt_now = true]; | ||
} | ||
|
||
message MapMinMax { | ||
map<string, bool> val = 1 [(buf.validate.field).map = { | ||
min_pairs: 2 | ||
max_pairs: 4 | ||
}]; | ||
} | ||
|
||
message MapKeys { | ||
map<sint64, string> val = 1 [(buf.validate.field).map.keys.sint64.lt = 0]; | ||
} | ||
|
||
message Embed { | ||
int64 val = 1 [(buf.validate.field).int64.gt = 0]; | ||
} | ||
message RepeatedEmbedSkip { | ||
repeated Embed val = 1 [(buf.validate.field).repeated.items.ignore = IGNORE_ALWAYS]; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that it's helpful to have local proto files for debugging. But
PROTOVALIDATE_VERSION
andbuf.lock
competing over the exact version seems like a footgun.Maybe the least controversial thing to do is to cut a protovalidate release that contains the new test protos?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m not following. pv-go is doing this exact thing with no issues. I would really prefer for this to follow that pattern. Being able to change protos while debugging issues is much quicker than constantly having to cut protovalidate releases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's good that we haven't had an issue with it so far. I didn't realize the Go implementation already does it. LGTM, and hopefully find a better solution down the road.