Skip to content

Commit

Permalink
main_test.go,testdata: Add non-nullable validated message field
Browse files Browse the repository at this point in the history
  • Loading branch information
rvolosatovs committed Feb 26, 2019
1 parent 829b499 commit a199579
Show file tree
Hide file tree
Showing 6 changed files with 306 additions and 47 deletions.
39 changes: 38 additions & 1 deletion main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ func TestFieldMaskPaths(t *testing.T) {
"a.a.d",
"a.a.h",
"a.a.h.nested_field",
"a.a.i",
"a.a.i.nested_field_2",
"a.a.testNestedNestedOneOf",
"a.a.testNestedNestedOneOf.e",
"a.a.testNestedNestedOneOf.f",
Expand All @@ -160,6 +162,8 @@ func TestFieldMaskPaths(t *testing.T) {
"b.a.d",
"b.a.h",
"b.a.h.nested_field",
"b.a.i",
"b.a.i.nested_field_2",
"b.a.testNestedNestedOneOf",
"b.a.testNestedNestedOneOf.e",
"b.a.testNestedNestedOneOf.f",
Expand All @@ -177,6 +181,8 @@ func TestFieldMaskPaths(t *testing.T) {
"c.a.d",
"c.a.h",
"c.a.h.nested_field",
"c.a.i",
"c.a.i.nested_field_2",
"c.a.testNestedNestedOneOf",
"c.a.testNestedNestedOneOf.e",
"c.a.testNestedNestedOneOf.f",
Expand Down Expand Up @@ -212,6 +218,8 @@ func TestFieldMaskPaths(t *testing.T) {
"a.d",
"a.h",
"a.h.nested_field",
"a.i",
"a.i.nested_field_2",
"a.testNestedNestedOneOf",
"a.testNestedNestedOneOf.e",
"a.testNestedNestedOneOf.f",
Expand All @@ -238,6 +246,8 @@ func TestFieldMaskPaths(t *testing.T) {
"d",
"h",
"h.nested_field",
"i",
"i.nested_field_2",
"testNestedNestedOneOf",
"testNestedNestedOneOf.e",
"testNestedNestedOneOf.f",
Expand All @@ -249,6 +259,7 @@ func TestFieldMaskPaths(t *testing.T) {
"c",
"d",
"h",
"i",
"testNestedNestedOneOf",
})
}
Expand Down Expand Up @@ -496,13 +507,16 @@ func TestValidateFields(t *testing.T) {
A: &testdata.Test_TestNested{
A: &testdata.Test_TestNested_TestNestedNested{
A: 42,
Test_TestNested_TestNestedNested_TestNestedNestedEmbed2: testdata.Test_TestNested_TestNestedNested_TestNestedNestedEmbed2{
NestedField_2: 2,
},
},
C: func(v time.Duration) *time.Duration { return &v }(43 * time.Second),
},
},
},
{
Name: "nil paths/invalid",
Name: "nil paths/invalid a.a.a",
Message: &testdata.Test{
A: &testdata.Test_TestNested{
A: &testdata.Test_TestNested_TestNestedNested{
Expand All @@ -512,6 +526,29 @@ func TestValidateFields(t *testing.T) {
},
ErrorAssertion: func(t *testing.T, err error) bool { return assertions.New(t).So(err, should.BeError) },
},
{
Name: "a.a.i/valid a.a.i.nested_field_2",
Message: &testdata.Test{
A: &testdata.Test_TestNested{
A: &testdata.Test_TestNested_TestNestedNested{
Test_TestNested_TestNestedNested_TestNestedNestedEmbed2: testdata.Test_TestNested_TestNestedNested_TestNestedNestedEmbed2{
NestedField_2: 2,
},
},
},
},
Paths: []string{"a.a.i"},
},
{
Name: "a.a.i/invalid a.a.i.nested_field_2",
Message: &testdata.Test{
A: &testdata.Test_TestNested{
A: &testdata.Test_TestNested_TestNestedNested{},
},
},
Paths: []string{"a.a.i"},
ErrorAssertion: func(t *testing.T, err error) bool { return assertions.New(t).So(err, should.BeError) },
},
{
Name: "non-existent sub-field",
Message: &testdata.Test{},
Expand Down
135 changes: 91 additions & 44 deletions testdata/testdata.pb.go

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

18 changes: 18 additions & 0 deletions testdata/testdata.pb.paths.fm.go

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

39 changes: 39 additions & 0 deletions testdata/testdata.pb.setters.fm.go

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

Loading

0 comments on commit a199579

Please sign in to comment.