Skip to content

Commit

Permalink
Build protos using the nullable option for testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
Johyn Papin committed Dec 14, 2023
1 parent 1025c29 commit dea18ea
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions protoc_plugin/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,16 @@ $(TEST_PROTO_LIBS): $(PLUGIN_SRC) $(TEST_PROTO_SRCS)
--plugin=protoc-gen-dart=$(realpath $(PLUGIN_PATH))\
$(TEST_PROTO_SRCS)

mkdir -p $(TEST_PROTO_DIR)/nullable

protoc\
--experimental_allow_proto3_optional\
--dart_out="nullable:$(TEST_PROTO_DIR)/nullable"\
-Iprotos\
-I$(TEST_PROTO_SRC_DIR)\
--plugin=protoc-gen-dart=$(realpath $(PLUGIN_PATH))\
$(TEST_PROTO_SRCS)

dart format $(TEST_PROTO_DIR)

update-pregenerated: $(PLUGIN_PATH) $(PREGENERATED_SRCS)
Expand Down
4 changes: 2 additions & 2 deletions protoc_plugin/test/unittest_proto3_test.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:test/test.dart';
import '../out/protos/google/protobuf/unittest_proto3.pb.dart';
import '../out/protos/nullable/google/protobuf/unittest_proto3.pb.dart';

void main() {
group('Optional fields should be nullable for', () {
Expand All @@ -16,7 +16,7 @@ void main() {
expect(obj2.optionalSingleInt32, null);
// should not generate linting errors
expect(obj2.optionalSingleInt32 ?? 1, 1);
expect(obj.hasOptionalSingleInt32(), false);
expect(obj2.hasOptionalSingleInt32(), false);
});
});
}

0 comments on commit dea18ea

Please sign in to comment.