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 Jan 16, 2024
1 parent dbe3620 commit 5413542
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 @@ -102,6 +102,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 5413542

Please sign in to comment.