forked from protocolbuffers/protobuf
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide UT that reproduces issue protocolbuffers#7
- Loading branch information
pierrick
committed
May 28, 2020
1 parent
b15ccb0
commit 169414c
Showing
3 changed files
with
158 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,34 @@ | ||
syntax = "proto3"; | ||
|
||
package foo.tester; | ||
|
||
import "google/protobuf/wrappers.proto"; | ||
import "google/protobuf/field_mask.proto"; | ||
|
||
message TestSuite { | ||
repeated TestCase test_cases = 1; | ||
} | ||
|
||
message TestCase { | ||
string description = 1; | ||
Resource original_resource = 2; | ||
Resource modified_resource = 3; | ||
google.protobuf.FieldMask expected_mask = 4; | ||
} | ||
|
||
message Resource { | ||
google.protobuf.StringValue wrapper = 1; | ||
Foo foo = 2; | ||
repeated Foo foos = 3; | ||
} | ||
|
||
message Foo { | ||
int64 num = 1; | ||
Bar bar = 2; | ||
repeated Bar bars = 3; | ||
} | ||
|
||
message Bar { | ||
int64 num = 1; | ||
google.protobuf.BoolValue nested_wrapper = 2; | ||
} |
This file contains 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 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,112 @@ | ||
{ | ||
"test_cases": [{ | ||
"description": "Modify scalar in a wrapper proto", | ||
"original_resource": { | ||
"wrapper": "a" | ||
}, | ||
"modified_resource": { | ||
"wrapper": "b" | ||
}, | ||
"expected_mask": "wrapper" | ||
}, { | ||
"description": "Create wrapper proto", | ||
"original_resource": { | ||
}, | ||
"modified_resource": { | ||
"wrapper": "a" | ||
}, | ||
"expected_mask": "wrapper" | ||
}, { | ||
"description": "Modify element in a repeated field", | ||
"original_resource": { | ||
"foos": [{ | ||
"num": 1 | ||
}, { | ||
"num": 2 | ||
}] | ||
}, | ||
"modified_resource": { | ||
"foos": [{ | ||
"num": 1 | ||
}, { | ||
"num": 3 | ||
}] | ||
}, | ||
"expected_mask": "foos" | ||
}, { | ||
"description": "Modify element in a nested repeated field", | ||
"original_resource": { | ||
"foos": [{ | ||
"bars": [{ | ||
"num": 1 | ||
}] | ||
}] | ||
}, | ||
"modified_resource": { | ||
"foos": [{ | ||
"bars": [{ | ||
"num": 2 | ||
}] | ||
}] | ||
}, | ||
"expected_mask": "foos" | ||
}, { | ||
"description": "Create submessage", | ||
"original_resource": { | ||
}, | ||
"modified_resource": { | ||
"foo": { | ||
"num": 1 | ||
} | ||
}, | ||
"expected_mask": "foo.num" | ||
}, { | ||
"description": "Modify submessage", | ||
"original_resource": { | ||
"foo": { | ||
} | ||
}, | ||
"modified_resource": { | ||
"foo": { | ||
"num": 1 | ||
} | ||
}, | ||
"expected_mask": "foo.num" | ||
}, { | ||
"description": "Clear submessage", | ||
"original_resource": { | ||
"foo": { | ||
} | ||
}, | ||
"modified_resource": { | ||
}, | ||
"expected_mask": "foo" | ||
}, { | ||
"description": "No change", | ||
"original_resource": { | ||
"wrapper": "a", | ||
"foos": [{ | ||
"num": 1 | ||
}] | ||
}, | ||
"modified_resource": { | ||
"wrapper": "a", | ||
"foos": [{ | ||
"num": 1 | ||
}] | ||
}, | ||
"expected_mask": {} | ||
}, { | ||
"description": "Create message with nested wrapper", | ||
"original_resource": { | ||
}, | ||
"modified_resource": { | ||
"foo": { | ||
"bar": { | ||
"nested_wrapper": true | ||
} | ||
} | ||
}, | ||
"expected_mask": "foo.bar.nested_wrapper" | ||
} | ||
]} |