File tree 2 files changed +20
-0
lines changed
2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -1029,6 +1029,12 @@ TEST(DynamicPatchTest, InvalidToPatchType) {
1029
1029
type::Type type = type::Type::get<type::union_t <MyUnion>>();
1030
1030
type.toThrift ().name ()->unionType_ref ()->scopedName_ref () = " scoped.name" ;
1031
1031
EXPECT_THROW (detail::toPatchType (type), std::runtime_error);
1032
+ EXPECT_THROW (
1033
+ detail::toPatchType (type::Type::get<type::infer_tag<MyStructPatch>>()),
1034
+ std::runtime_error);
1035
+ EXPECT_THROW (
1036
+ detail::toPatchType (type::Type::get<type::struct_t <MyStructSafePatch>>()),
1037
+ std::runtime_error);
1032
1038
}
1033
1039
1034
1040
TEST (DynamicPatchTest, ToSafePatchType) {
@@ -1044,6 +1050,12 @@ TEST(DynamicPatchTest, ToSafePatchType) {
1044
1050
unionScopedName.toThrift ().name ()->unionType_ref ()->scopedName_ref () =
1045
1051
" scoped.name" ;
1046
1052
EXPECT_THROW (toSafePatchType (unionScopedName), std::runtime_error);
1053
+ EXPECT_THROW (
1054
+ toSafePatchType (type::Type::get<type::infer_tag<MyStructPatch>>()),
1055
+ std::runtime_error);
1056
+ EXPECT_THROW (
1057
+ toSafePatchType (type::Type::get<type::struct_t <MyStructSafePatch>>()),
1058
+ std::runtime_error);
1047
1059
}
1048
1060
1049
1061
TEST (DynamicPatchTest, AnyPatch) {
Original file line number Diff line number Diff line change @@ -280,13 +280,21 @@ void checkHomogeneousContainer(const ValueMap& m) {
280
280
}
281
281
282
282
std::string toSafePatchUri (std::string s) {
283
+ if (folly::StringPiece (s).endsWith (kPatchUriSuffix )) {
284
+ folly::throw_exception<std::runtime_error>(
285
+ fmt::format (" Uri {} is already Patch." , s));
286
+ }
283
287
s += kSafePatchUriSuffix ;
284
288
return s;
285
289
}
286
290
287
291
} // namespace detail
288
292
289
293
std::string toPatchUri (std::string s) {
294
+ if (folly::StringPiece (s).endsWith (detail::kPatchUriSuffix )) {
295
+ folly::throw_exception<std::runtime_error>(
296
+ fmt::format (" Uri {} is already Patch." , s));
297
+ }
290
298
s += detail::kPatchUriSuffix ;
291
299
return s;
292
300
}
You can’t perform that action at this time.
0 commit comments