Skip to content

Commit

Permalink
test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
lukealvoeiro committed May 9, 2024
1 parent 5d30dc6 commit 46e0c96
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
17 changes: 2 additions & 15 deletions integration/options-types-only/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import { FileDescriptorProto as FileDescriptorProto1 } from "ts-proto-descriptors";
import { protoMetadata as protoMetadata1 } from "./google/protobuf/descriptor";
import { protoMetadata as protoMetadata2 } from "./something/something";
import type { Something } from "./something/something";

export const protobufPackage = "";

Expand Down Expand Up @@ -325,23 +324,11 @@ export const protoMetadata: ProtoMetadata = {
messages: {
"MyMessage": {
options: { "my_message_option": 1234 },
fields: {
"foo": { "my_field_option": 4.5 },
"foo_2": { "something": Something.decode(Buffer.from("CgV3b3JsZBIDe9kC", "base64")) },
},
fields: { "foo": { "my_field_option": 4.5 } },
oneof: { "qux": { "my_oneof_option": 42 } },
},
},
services: {
"MyService": {
options: { "my_service_option": 0 },
methods: {
"MyMethod": {
"my_method_option": MyMessage.decode(Buffer.from("CJYBEJYBGgtTb21lIHN0cmluZyILU29tZSBzdHJpbmc=", "base64")),
},
},
},
},
services: { "MyService": { options: { "my_service_option": 0 }, methods: {} } },
enums: { "MyEnum": { options: { "my_enum_option": true }, values: { "FOO": { "my_enum_value_option": 321 } } } },
},
};
6 changes: 4 additions & 2 deletions src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ function encodedOptionsToOptions(
// We should fix this so that we can always create an option definition by
// somehow premptively decoding the encoded value and then inserting it into
// the option defintion.
// please refer to inteegration/options-types-only to see this in action
resultOptions.push(getExtensionValue(ctx, extension, value));
}
}
Expand All @@ -257,8 +258,9 @@ function encodedOptionsToOptions(

function shouldAddOptionDefinition(ctx: Context, extension: FieldDescriptorProto) {
return (
extension.type == FieldDescriptorProto_Type.TYPE_MESSAGE &&
(ctx.options.outputEncodeMethods === true || ctx.options.outputEncodeMethods == "decode-only")
extension.type !== FieldDescriptorProto_Type.TYPE_MESSAGE ||
ctx.options.outputEncodeMethods === true ||
ctx.options.outputEncodeMethods == "decode-only"
);
}

Expand Down

0 comments on commit 46e0c96

Please sign in to comment.