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

WIP: add test for option in message descriptors #125

Closed
wants to merge 1 commit into from
Closed
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
16 changes: 14 additions & 2 deletions prost-reflect-tests/src/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ use serde_json::json;
use crate::{
arbitrary,
proto::{
contains_group, message_with_oneof, ComplexType, ContainsGroup, MessageWithAliasedEnum,
MessageWithOneof, Point, ScalarArrays, Scalars, WellKnownTypes,
contains_group, message_with_oneof, options::Aggregate, ComplexType, ContainsGroup, MessageWithAliasedEnum, MessageWithOneof, Point, ScalarArrays, Scalars, WellKnownTypes
},
test_file_descriptor,
};
Expand Down Expand Up @@ -884,6 +883,19 @@ fn serialize_any_wkt() {
);
}

#[test]
fn serialize_options() {
let json = to_json(
Aggregate::default().descriptor().descriptor_proto()
Copy link
Owner

@andrewhickman andrewhickman Jul 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

descriptor_proto returns a prost_types::MessageDescriptor, which doesn't have support for extension fields/options, so unfortunately there's no way for this to work until tokio-rs/prost#1031 is implemented.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why this is bound to the edition stuff. custom options have been available in protobuf much before edition has been introduced. the nearest issue I see is tokio-rs/prost#754

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're right, that is not the issue I intended to link. tokio-rs/prost#674 tracks support for extension fields

);
let options = json.get("options").unwrap();
// Aggregate message descriptor should have some options
assert_ne!(
options.as_object().unwrap().len(),
0
);
}

#[test]
fn deserialize_any() {
let value: prost_types::Any = from_json(
Expand Down
Loading