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

Disable deprecated proto2 groups #630

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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

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

2 changes: 1 addition & 1 deletion packages/protobuf-test/extra/proto2.proto
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,4 @@ enum Proto2Enum {

message Proto2ChildMessage {
optional string string_field = 1;
}
}
43 changes: 43 additions & 0 deletions packages/protobuf-test/src/descriptor-set.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,49 @@ describe("DescriptorSet", () => {
);
});
});
describe("proto2 groups", () => {
test("simple group isLegacyProto2Group", async () => {
const bin = await new UpstreamProtobuf().compileToDescriptorSet(`
syntax="proto2";
message M {
optional group G = 1 {}
}
`);
const { messages } = createDescriptorSet(bin);
const M = messages.get("M");
expect(M?.isLegacyProto2Group()).toBe(false);
const G = messages.get("M.G");
expect(G?.isLegacyProto2Group()).toBe(true);
expect(M?.fields[0].message).toBe(G);
});
test("nested group isLegacyProto2Group", async () => {
const bin = await new UpstreamProtobuf().compileToDescriptorSet(`
syntax="proto2";
message M {
optional group GroupA = 1 {
optional group GroupB = 1 {}
}
}
`);
const { messages } = createDescriptorSet(bin);
const GroupB = messages.get("M.GroupA.GroupB");
expect(GroupB?.isLegacyProto2Group()).toBe(true);
});
test("extension with group isLegacyProto2Group", async () => {
const bin = await new UpstreamProtobuf().compileToDescriptorSet(`
syntax="proto2";
message M {
extensions 100 to 1010;
}
extend M {
optional group G = 100 {}
}
`);
const { messages } = createDescriptorSet(bin);
const G = messages.get("G");
expect(G?.isLegacyProto2Group()).toBe(true);
});
});
describe("repeated field packing", () => {
test("proto2 is unpacked by default", async () => {
const bin = await new UpstreamProtobuf().compileToDescriptorSet(`
Expand Down
Loading