From bdf1c9355e6e0cba205cc09917bd360c138b5681 Mon Sep 17 00:00:00 2001 From: Roman Volosatovs Date: Tue, 26 Feb 2019 14:54:10 +0100 Subject: [PATCH 1/2] go.sum: Update protoc-gen-validate --- go.sum | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.sum b/go.sum index 21d8b57..a6a2f82 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,6 @@ github.com/TheThingsIndustries/protoc-gen-star v0.4.7-gogo h1:vtoerBb3MHbzeUM0+w/bBpIhzT+yCaD1QrDN1/p7F2A= github.com/TheThingsIndustries/protoc-gen-star v0.4.7-gogo/go.mod h1:lIqzPBz4CG/TSsK9fPQvo7iVfbxEWc+76AVxeiHMcT4= -github.com/TheThingsIndustries/protoc-gen-validate v0.0.13-fieldmask h1:vIdGpbSKd0SJJoC+BEZc/17W+N3CKh6qjfpXKbyCw7g= +github.com/TheThingsIndustries/protoc-gen-validate v0.0.13-fieldmask h1:ceerwKg0M/jOU1sdjzHx3k+KsFIZ2LyrNNT+EVXW/AI= github.com/TheThingsIndustries/protoc-gen-validate v0.0.13-fieldmask/go.mod h1:65OEzdQPsbLDokGIF3GQjCTWOuuVuHqxh7a08yYe0tw= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= From 95d612720f3b7cf111ae1217f55869df50c9973a Mon Sep 17 00:00:00 2001 From: Roman Volosatovs Date: Tue, 26 Feb 2019 14:58:34 +0100 Subject: [PATCH 2/2] main_test.go,testdata: Add repeated field tests --- main_test.go | 5 ++ testdata/testdata.pb.go | 102 ++++++++++++++++------------- testdata/testdata.pb.paths.fm.go | 5 ++ testdata/testdata.pb.setters.fm.go | 9 +++ testdata/testdata.pb.validate.go | 17 +++++ testdata/testdata.proto | 1 + 6 files changed, 92 insertions(+), 47 deletions(-) diff --git a/main_test.go b/main_test.go index 173481d..cc9663e 100644 --- a/main_test.go +++ b/main_test.go @@ -154,6 +154,7 @@ func TestFieldMaskPaths(t *testing.T) { "a.d", "a.e", "a.f", + "a.g", "b", "b.a", "b.a.a", @@ -173,6 +174,7 @@ func TestFieldMaskPaths(t *testing.T) { "b.d", "b.e", "b.f", + "b.g", "c", "c.a", "c.a.a", @@ -192,6 +194,7 @@ func TestFieldMaskPaths(t *testing.T) { "c.d", "c.e", "c.f", + "c.g", "g", "h", "i", @@ -229,6 +232,7 @@ func TestFieldMaskPaths(t *testing.T) { "d", "e", "f", + "g", }) a.So(testdata.Test_TestNestedFieldPathsTopLevel, should.Resemble, []string{ "a", @@ -237,6 +241,7 @@ func TestFieldMaskPaths(t *testing.T) { "d", "e", "f", + "g", }) a.So(testdata.Test_TestNested_TestNestedNestedFieldPathsNested, should.Resemble, []string{ diff --git a/testdata/testdata.pb.go b/testdata/testdata.pb.go index c7c2f06..bcb93bd 100644 --- a/testdata/testdata.pb.go +++ b/testdata/testdata.pb.go @@ -273,6 +273,7 @@ type Test_TestNested struct { D *time.Time `protobuf:"bytes,4,opt,name=d,proto3,stdtime" json:"d,omitempty"` E *github_com_TheThingsIndustries_protoc_gen_fieldmask_testdata_testpackage.CustomType `protobuf:"bytes,5,opt,name=e,proto3,customtype=github.com/TheThingsIndustries/protoc-gen-fieldmask/testdata/testpackage.CustomType" json:"e,omitempty"` F github_com_TheThingsIndustries_protoc_gen_fieldmask_testdata_testpackage.CustomType `protobuf:"bytes,6,opt,name=f,proto3,customtype=github.com/TheThingsIndustries/protoc-gen-fieldmask/testdata/testpackage.CustomType" json:"f"` + G []*Test_TestNested_TestNestedNested `protobuf:"bytes,7,rep,name=g,proto3" json:"g,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -330,6 +331,13 @@ func (m *Test_TestNested) GetD() *time.Time { return nil } +func (m *Test_TestNested) GetG() []*Test_TestNested_TestNestedNested { + if m != nil { + return m.G + } + return nil +} + type Test_TestNested_TestNestedNested struct { A int32 `protobuf:"varint,1,opt,name=a,proto3" json:"a,omitempty"` B int64 `protobuf:"fixed64,2,opt,name=b,proto3" json:"b,omitempty"` @@ -633,51 +641,51 @@ func init() { func init() { proto.RegisterFile("testdata.proto", fileDescriptor_40c4782d007dfce9) } var fileDescriptor_40c4782d007dfce9 = []byte{ - // 721 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x94, 0xcb, 0x6e, 0xd3, 0x4c, - 0x14, 0xc7, 0x3b, 0x89, 0x93, 0x26, 0x93, 0x34, 0x8d, 0xe6, 0xfb, 0x0a, 0xae, 0x05, 0x38, 0x94, - 0x05, 0x51, 0x44, 0x1c, 0x08, 0x15, 0x94, 0x82, 0xb8, 0x98, 0x16, 0xd1, 0x4d, 0x2b, 0xb9, 0x01, - 0x04, 0x2c, 0xaa, 0x49, 0x3c, 0x76, 0xac, 0xc6, 0x17, 0xd9, 0x93, 0xa2, 0xec, 0x79, 0x00, 0x96, - 0x3c, 0x03, 0x8f, 0xc0, 0x8a, 0x25, 0x4b, 0xd6, 0x2c, 0x52, 0xa9, 0x3b, 0x16, 0x48, 0x3c, 0x02, - 0x9a, 0x99, 0x18, 0x9b, 0xa4, 0x55, 0x41, 0x15, 0x9b, 0xe8, 0x9c, 0x39, 0x97, 0x99, 0xf3, 0x3b, - 0x7f, 0x07, 0x56, 0x28, 0x89, 0xa8, 0x89, 0x29, 0xd6, 0x82, 0xd0, 0xa7, 0x3e, 0x2a, 0xc4, 0xbe, - 0xd2, 0xb4, 0x1d, 0xda, 0x1f, 0x76, 0xb5, 0x9e, 0xef, 0xb6, 0x6c, 0xdf, 0xf6, 0x5b, 0x3c, 0xa1, - 0x3b, 0xb4, 0xb8, 0xc7, 0x1d, 0x6e, 0x89, 0x42, 0xe5, 0x6e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 0x78, 0x64, 0xc7, - 0xd2, 0x4b, 0xb0, 0xc8, 0x02, 0xfc, 0x5f, 0x4a, 0xbf, 0xff, 0xea, 0xde, 0x59, 0x94, 0xdd, 0xcd, - 0xf3, 0xf0, 0xcd, 0x9f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xcb, 0x88, 0xb1, 0x92, 0xa8, 0x06, 0x00, - 0x00, + // 729 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x54, 0xcd, 0x6e, 0xd3, 0x4a, + 0x14, 0xee, 0x24, 0x4e, 0x9a, 0x4c, 0xd2, 0x34, 0x9a, 0x7b, 0x7b, 0xaf, 0x6b, 0x01, 0x0e, 0x65, + 0x41, 0x14, 0x11, 0x07, 0x42, 0x05, 0xa5, 0x20, 0x7e, 0x4c, 0x8b, 0xe8, 0xa6, 0x95, 0xdc, 0x00, + 0x02, 0x16, 0xd5, 0x24, 0x1e, 0x3b, 0x56, 0xe3, 0x1f, 0xd9, 0x93, 0xa2, 0xbc, 0x05, 0x4b, 0xde, + 0x00, 0x89, 0x47, 0x60, 0x81, 0x58, 0xb2, 0x64, 0xcd, 0x22, 0x95, 0xba, 0x63, 0xc7, 0x23, 0xa0, + 0x99, 0x89, 0xb1, 0x49, 0x5a, 0x95, 0xaa, 0x62, 0x63, 0xcd, 0x99, 0xf3, 0x33, 0xe7, 0x7c, 0xdf, + 0x77, 0x0c, 0x2b, 0x94, 0x44, 0xd4, 0xc4, 0x14, 0x6b, 0x41, 0xe8, 0x53, 0x1f, 0x15, 0x62, 0x5b, + 0x69, 0xda, 0x0e, 0xed, 0x0f, 0xbb, 0x5a, 0xcf, 0x77, 0x5b, 0xb6, 0x6f, 0xfb, 0x2d, 0x1e, 0xd0, + 0x1d, 0x5a, 0xdc, 0xe2, 0x06, 0x3f, 0x89, 0x44, 0xe5, 0x6e, 0x2a, 0x7c, 0x30, 0xb2, 0xa8, 0x08, + 0xef, 0x35, 0x6d, 0xe2, 0x35, 0x0f, 0xf0, 0xc0, 0x31, 0x31, 0x25, 0xad, 0x99, 0xc3, 0x24, 0xf9, + 0x92, 0xed, 0xfb, 0xf6, 0x80, 0x24, 0x4f, 0x98, 0xc3, 0x10, 0x53, 0xc7, 0xf7, 0x26, 0x7e, 0x75, + 0xda, 0x4f, 0x1d, 0x97, 0x44, 0x14, 0xbb, 0xc1, 0x49, 0x05, 0xde, 0x84, 0x38, 0x08, 0x48, 0x18, + 0x09, 0xff, 0xca, 0x3c, 0xcc, 0x6d, 0xba, 0x01, 0x1d, 0xad, 0xbc, 0x2f, 0x41, 0xa9, 0x43, 0x22, + 0x8a, 0xae, 0x42, 0x80, 0x65, 0x50, 0x03, 0xf5, 0x52, 0x7b, 0x59, 0xfb, 0x05, 0x02, 0x73, 0xf1, + 0xcf, 0x36, 0x89, 0x28, 0x31, 0x0d, 0x80, 0xd1, 0x6d, 0x08, 0xba, 0x72, 0xe6, 0x94, 0x40, 0xbd, + 0x72, 0x34, 0x56, 0xe1, 0xe3, 0x61, 0x44, 0x7d, 0x77, 0x1b, 0xbb, 0xc4, 0x00, 0x5d, 0xd4, 0x84, + 0xa0, 0x27, 0x67, 0x4f, 0x4b, 0x94, 0xbe, 0x8c, 0xd5, 0x39, 0x03, 0xf4, 0x50, 0x05, 0x02, 0x53, + 0x96, 0x6a, 0xa0, 0x9e, 0x7b, 0x3a, 0x67, 0x00, 0x13, 0x5d, 0x81, 0x80, 0xc8, 0xb9, 0x1a, 0xa8, + 0x2f, 0xe8, 0xff, 0x1c, 0x8d, 0xd5, 0xc5, 0xa4, 0xf8, 0x8e, 0x47, 0x7c, 0x8b, 0x05, 0x11, 0x96, + 0x64, 0xc9, 0xf9, 0x1a, 0xa8, 0x97, 0x99, 0x6d, 0xa1, 0x8b, 0x10, 0xd8, 0xf2, 0x3c, 0x7f, 0x73, + 0x31, 0x79, 0x93, 0x8f, 0x6e, 0x00, 0x1b, 0x35, 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c7, 0x23, 0x3b, 0x96, 0x5e, 0x82, 0x45, 0xe6, 0xe0, 0xff, 0x37, + 0xfd, 0xfe, 0xab, 0x7b, 0xe7, 0xd9, 0x89, 0x6e, 0x9e, 0xbb, 0x6f, 0xfe, 0x0c, 0x00, 0x00, 0xff, + 0xff, 0xa8, 0x26, 0xca, 0x89, 0xe2, 0x06, 0x00, 0x00, } diff --git a/testdata/testdata.pb.paths.fm.go b/testdata/testdata.pb.paths.fm.go index 7119820..f31268c 100644 --- a/testdata/testdata.pb.paths.fm.go +++ b/testdata/testdata.pb.paths.fm.go @@ -24,6 +24,7 @@ var TestFieldPathsNested = []string{ "a.d", "a.e", "a.f", + "a.g", "b", "b.a", "b.a.a", @@ -43,6 +44,7 @@ var TestFieldPathsNested = []string{ "b.d", "b.e", "b.f", + "b.g", "c", "c.a", "c.a.a", @@ -62,6 +64,7 @@ var TestFieldPathsNested = []string{ "c.d", "c.e", "c.f", + "c.g", "g", "h", "i", @@ -99,6 +102,7 @@ var Test_TestNestedFieldPathsNested = []string{ "d", "e", "f", + "g", } var Test_TestNestedFieldPathsTopLevel = []string{ @@ -108,6 +112,7 @@ var Test_TestNestedFieldPathsTopLevel = []string{ "d", "e", "f", + "g", } var Test_TestNested_TestNestedNestedFieldPathsNested = []string{ "a", diff --git a/testdata/testdata.pb.setters.fm.go b/testdata/testdata.pb.setters.fm.go index 6a9e9a0..c01870f 100644 --- a/testdata/testdata.pb.setters.fm.go +++ b/testdata/testdata.pb.setters.fm.go @@ -258,6 +258,15 @@ func (dst *Test_TestNested) SetFields(src *Test_TestNested, paths ...string) err var zero github_com_TheThingsIndustries_protoc_gen_fieldmask_testdata_testpackage.CustomType dst.F = zero } + case "g": + if len(subs) > 0 { + return fmt.Errorf("'g' has no subfields, but %s were specified", subs) + } + if src != nil { + dst.G = src.G + } else { + dst.G = nil + } default: return fmt.Errorf("invalid field: '%s'", name) diff --git a/testdata/testdata.pb.validate.go b/testdata/testdata.pb.validate.go index 8bb69a6..182b3cb 100644 --- a/testdata/testdata.pb.validate.go +++ b/testdata/testdata.pb.validate.go @@ -324,6 +324,23 @@ func (m *Test_TestNested) ValidateFields(paths ...string) error { // no validation rules for E case "f": // no validation rules for F + case "g": + + for idx, item := range m.GetG() { + _, _ = idx, item + + if v, ok := interface{}(item).(interface{ ValidateFields(...string) error }); ok { + if err := v.ValidateFields(subs...); err != nil { + return Test_TestNestedValidationError{ + field: fmt.Sprintf("g[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + default: return Test_TestNestedValidationError{ field: name, diff --git a/testdata/testdata.proto b/testdata/testdata.proto index ca63f83..b3eeace 100644 --- a/testdata/testdata.proto +++ b/testdata/testdata.proto @@ -54,6 +54,7 @@ message Test { google.protobuf.Timestamp d = 4 [(gogoproto.stdtime) = true]; string e = 5 [(gogoproto.customtype) = "github.com/TheThingsIndustries/protoc-gen-fieldmask/testdata/testpackage.CustomType"]; string f = 6 [(gogoproto.customtype) = "github.com/TheThingsIndustries/protoc-gen-fieldmask/testdata/testpackage.CustomType", (gogoproto.nullable) = false]; + repeated TestNestedNested g = 7; } TestNested a = 1; TestNested b = 2 [(gogoproto.customname) = "CustomName"];