Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit aa7210e

Browse files
committedMar 20, 2024··
Build protos using the nullable option for testing.
Signed-off-by: Chito <[email protected]>
1 parent d0f4e55 commit aa7210e

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed
 

‎protoc_plugin/Makefile

+10
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,16 @@ $(TEST_PROTO_LIBS): $(PLUGIN_SRC) $(TEST_PROTO_SRCS)
102102
--plugin=protoc-gen-dart=$(realpath $(PLUGIN_PATH))\
103103
$(TEST_PROTO_SRCS)
104104

105+
mkdir -p $(TEST_PROTO_DIR)/nullable
106+
107+
protoc\
108+
--experimental_allow_proto3_optional\
109+
--dart_out="nullable:$(TEST_PROTO_DIR)/nullable"\
110+
-Iprotos\
111+
-I$(TEST_PROTO_SRC_DIR)\
112+
--plugin=protoc-gen-dart=$(realpath $(PLUGIN_PATH))\
113+
$(TEST_PROTO_SRCS)
114+
105115
dart format $(TEST_PROTO_DIR)
106116

107117
update-pregenerated: $(PLUGIN_PATH) $(PREGENERATED_SRCS)

‎protoc_plugin/test/unittest_proto3_test.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import 'package:test/test.dart';
2-
import '../out/protos/google/protobuf/unittest_proto3.pb.dart';
2+
import '../out/protos/nullable/google/protobuf/unittest_proto3.pb.dart';
33

44
void main() {
55
group('Optional fields should be nullable for', () {
@@ -16,7 +16,7 @@ void main() {
1616
expect(obj2.optionalSingleInt32, null);
1717
// should not generate linting errors
1818
expect(obj2.optionalSingleInt32 ?? 1, 1);
19-
expect(obj.hasOptionalSingleInt32(), false);
19+
expect(obj2.hasOptionalSingleInt32(), false);
2020
});
2121
});
2222
}

0 commit comments

Comments
 (0)
Please sign in to comment.