Skip to content

Commit

Permalink
feat userver: adjust tests and code after reformatting
Browse files Browse the repository at this point in the history
Tests: протестировано CI
commit_hash:0f072fd361e3bcecb8ef7e500ff39303035b27b9
  • Loading branch information
apolukhin committed Oct 20, 2024
1 parent 08d314a commit 1f968ab
Show file tree
Hide file tree
Showing 15 changed files with 230 additions and 289 deletions.
8 changes: 4 additions & 4 deletions chaotic/golden_tests/output/schemas/allof/allof.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ AllOf Parse(USERVER_NAMESPACE::formats::json::Value json, USERVER_NAMESPACE::for
return Parse<USERVER_NAMESPACE::formats::json::Value>(json, to);
}

/* Parse(USERVER_NAMESPACE::formats::yaml::Value, To<ns::AllOf>) was not
* generated: ns::AllOf::Foo__P0 has JSON-specific field "extra" */
/* Parse(USERVER_NAMESPACE::formats::yaml::Value, To<ns::AllOf>) was not generated: ns::AllOf::Foo__P0 has JSON-specific
* field "extra" */

/* Parse(USERVER_NAMESPACE::yaml_config::Value, To<ns::AllOf>) was not
* generated: ns::AllOf::Foo__P0 has JSON-specific field "extra" */
/* Parse(USERVER_NAMESPACE::yaml_config::Value, To<ns::AllOf>) was not generated: ns::AllOf::Foo__P0 has JSON-specific
* field "extra" */

USERVER_NAMESPACE::formats::json::Value
Serialize([[maybe_unused]] const ns::AllOf::Foo__P0& value, USERVER_NAMESPACE::formats::serialize::To<USERVER_NAMESPACE::formats::json::Value>) {
Expand Down
8 changes: 4 additions & 4 deletions chaotic/golden_tests/output/schemas/allof/allof.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ AllOf::Foo Parse(USERVER_NAMESPACE::formats::json::Value json, USERVER_NAMESPACE

AllOf Parse(USERVER_NAMESPACE::formats::json::Value json, USERVER_NAMESPACE::formats::parse::To<ns::AllOf>);

/* Parse(USERVER_NAMESPACE::formats::yaml::Value, To<ns::AllOf>) was not
* generated: ns::AllOf::Foo__P0 has JSON-specific field "extra" */
/* Parse(USERVER_NAMESPACE::formats::yaml::Value, To<ns::AllOf>) was not generated: ns::AllOf::Foo__P0 has JSON-specific
* field "extra" */

/* Parse(USERVER_NAMESPACE::yaml_config::Value, To<ns::AllOf>) was not
* generated: ns::AllOf::Foo__P0 has JSON-specific field "extra" */
/* Parse(USERVER_NAMESPACE::yaml_config::Value, To<ns::AllOf>) was not generated: ns::AllOf::Foo__P0 has JSON-specific
* field "extra" */

USERVER_NAMESPACE::formats::json::Value
Serialize(const ns::AllOf::Foo__P0& value, USERVER_NAMESPACE::formats::serialize::To<USERVER_NAMESPACE::formats::json::Value>);
Expand Down
80 changes: 32 additions & 48 deletions chaotic/golden_tests/output/schemas/allof/allof_parsers.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -13,80 +13,64 @@

namespace ns {

static constexpr USERVER_NAMESPACE::utils::TrivialSet
kns__AllOf__Foo__P0_PropertiesNames = [](auto selector) {
return selector().template Type<std::string_view>().Case("foo");
};
static constexpr USERVER_NAMESPACE::utils::TrivialSet kns__AllOf__Foo__P0_PropertiesNames = [](auto selector) {
return selector().template Type<std::string_view>().Case("foo");
};

static constexpr USERVER_NAMESPACE::utils::TrivialSet
kns__AllOf__Foo__P1_PropertiesNames = [](auto selector) {
return selector().template Type<std::string_view>().Case("bar");
};
static constexpr USERVER_NAMESPACE::utils::TrivialSet kns__AllOf__Foo__P1_PropertiesNames = [](auto selector) {
return selector().template Type<std::string_view>().Case("bar");
};

static constexpr USERVER_NAMESPACE::utils::TrivialSet
kns__AllOf_PropertiesNames = [](auto selector) {
return selector().template Type<std::string_view>().Case("foo");
};
static constexpr USERVER_NAMESPACE::utils::TrivialSet kns__AllOf_PropertiesNames = [](auto selector) {
return selector().template Type<std::string_view>().Case("foo");
};

template <typename Value>
ns::AllOf::Foo__P0 Parse(
Value value, USERVER_NAMESPACE::formats::parse::To<ns::AllOf::Foo__P0>) {
value.CheckNotMissing();
value.CheckObjectOrNull();
ns::AllOf::Foo__P0 Parse(Value value, USERVER_NAMESPACE::formats::parse::To<ns::AllOf::Foo__P0>) {
value.CheckNotMissing();
value.CheckObjectOrNull();

ns::AllOf::Foo__P0 res;
ns::AllOf::Foo__P0 res;

res.foo = value["foo"]
.template As<std::optional<
USERVER_NAMESPACE::chaotic::Primitive<std::string>>>();
res.foo = value["foo"].template As<std::optional<USERVER_NAMESPACE::chaotic::Primitive<std::string>>>();

res.extra = USERVER_NAMESPACE::chaotic::ExtractAdditionalPropertiesTrue(
value, kns__AllOf__Foo__P0_PropertiesNames);
res.extra = USERVER_NAMESPACE::chaotic::ExtractAdditionalPropertiesTrue(value, kns__AllOf__Foo__P0_PropertiesNames);

return res;
return res;
}

template <typename Value>
ns::AllOf::Foo__P1 Parse(
Value value, USERVER_NAMESPACE::formats::parse::To<ns::AllOf::Foo__P1>) {
value.CheckNotMissing();
value.CheckObjectOrNull();
ns::AllOf::Foo__P1 Parse(Value value, USERVER_NAMESPACE::formats::parse::To<ns::AllOf::Foo__P1>) {
value.CheckNotMissing();
value.CheckObjectOrNull();

ns::AllOf::Foo__P1 res;
ns::AllOf::Foo__P1 res;

res.bar =
value["bar"]
.template As<
std::optional<USERVER_NAMESPACE::chaotic::Primitive<int>>>();
res.bar = value["bar"].template As<std::optional<USERVER_NAMESPACE::chaotic::Primitive<int>>>();

res.extra = USERVER_NAMESPACE::chaotic::ExtractAdditionalPropertiesTrue(
value, kns__AllOf__Foo__P1_PropertiesNames);
res.extra = USERVER_NAMESPACE::chaotic::ExtractAdditionalPropertiesTrue(value, kns__AllOf__Foo__P1_PropertiesNames);

return res;
return res;
}

template <typename Value>
ns::AllOf::Foo Parse(Value value,
USERVER_NAMESPACE::formats::parse::To<ns::AllOf::Foo>) {
return ns::AllOf::Foo(value.template As<ns::AllOf::Foo__P0>(),
value.template As<ns::AllOf::Foo__P1>());
ns::AllOf::Foo Parse(Value value, USERVER_NAMESPACE::formats::parse::To<ns::AllOf::Foo>) {
return ns::AllOf::Foo(value.template As<ns::AllOf::Foo__P0>(), value.template As<ns::AllOf::Foo__P1>());
}

template <typename Value>
ns::AllOf Parse(Value value, USERVER_NAMESPACE::formats::parse::To<ns::AllOf>) {
value.CheckNotMissing();
value.CheckObjectOrNull();
value.CheckNotMissing();
value.CheckObjectOrNull();

ns::AllOf res;
ns::AllOf res;

res.foo = value["foo"]
.template As<std::optional<
USERVER_NAMESPACE::chaotic::Primitive<ns::AllOf::Foo>>>();
res.foo = value["foo"].template As<std::optional<USERVER_NAMESPACE::chaotic::Primitive<ns::AllOf::Foo>>>();

USERVER_NAMESPACE::chaotic::ValidateNoAdditionalProperties(
value, kns__AllOf_PropertiesNames);
USERVER_NAMESPACE::chaotic::ValidateNoAdditionalProperties(value, kns__AllOf_PropertiesNames);

return res;
return res;
}

} // namespace ns

59 changes: 27 additions & 32 deletions chaotic/golden_tests/output/schemas/enum/enum_parsers.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -12,48 +12,43 @@

namespace ns {

static constexpr USERVER_NAMESPACE::utils::TrivialBiMap kns__Enum__Foo_Mapping =
[](auto selector) {
return selector()
.template Type<ns::Enum::Foo, std::string_view>()
.Case(ns::Enum::Foo::kOne, "one")
.Case(ns::Enum::Foo::kTwo, "two")
.Case(ns::Enum::Foo::kThree, "three");
};

static constexpr USERVER_NAMESPACE::utils::TrivialSet
kns__Enum_PropertiesNames = [](auto selector) {
return selector().template Type<std::string_view>().Case("foo");
};
static constexpr USERVER_NAMESPACE::utils::TrivialBiMap kns__Enum__Foo_Mapping = [](auto selector) {
return selector()
.template Type<ns::Enum::Foo, std::string_view>()
.Case(ns::Enum::Foo::kOne, "one")
.Case(ns::Enum::Foo::kTwo, "two")
.Case(ns::Enum::Foo::kThree, "three");
};

static constexpr USERVER_NAMESPACE::utils::TrivialSet kns__Enum_PropertiesNames = [](auto selector) {
return selector().template Type<std::string_view>().Case("foo");
};

template <typename Value>
ns::Enum::Foo Parse(Value val,
USERVER_NAMESPACE::formats::parse::To<ns::Enum::Foo>) {
const auto value = val.template As<std::string>();
const auto result = kns__Enum__Foo_Mapping.TryFindBySecond(value);
if (result.has_value()) {
return *result;
}
USERVER_NAMESPACE::chaotic::ThrowForValue(
fmt::format("Invalid enum value ({}) for type ns::Enum::Foo", value),
val);
ns::Enum::Foo Parse(Value val, USERVER_NAMESPACE::formats::parse::To<ns::Enum::Foo>) {
const auto value = val.template As<std::string>();
const auto result = kns__Enum__Foo_Mapping.TryFindBySecond(value);
if (result.has_value()) {
return *result;
}
USERVER_NAMESPACE::chaotic::ThrowForValue(
fmt::format("Invalid enum value ({}) for type ns::Enum::Foo", value), val
);
}

template <typename Value>
ns::Enum Parse(Value value, USERVER_NAMESPACE::formats::parse::To<ns::Enum>) {
value.CheckNotMissing();
value.CheckObjectOrNull();
value.CheckNotMissing();
value.CheckObjectOrNull();

ns::Enum res;
ns::Enum res;

res.foo = value["foo"]
.template As<std::optional<
USERVER_NAMESPACE::chaotic::Primitive<ns::Enum::Foo>>>();
res.foo = value["foo"].template As<std::optional<USERVER_NAMESPACE::chaotic::Primitive<ns::Enum::Foo>>>();

USERVER_NAMESPACE::chaotic::ValidateNoAdditionalProperties(
value, kns__Enum_PropertiesNames);
USERVER_NAMESPACE::chaotic::ValidateNoAdditionalProperties(value, kns__Enum_PropertiesNames);

return res;
return res;
}

} // namespace ns

24 changes: 10 additions & 14 deletions chaotic/golden_tests/output/schemas/int/int_parsers.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,23 @@

namespace ns {

static constexpr USERVER_NAMESPACE::utils::TrivialSet kns__Int_PropertiesNames =
[](auto selector) {
return selector().template Type<std::string_view>().Case("foo");
};
static constexpr USERVER_NAMESPACE::utils::TrivialSet kns__Int_PropertiesNames = [](auto selector) {
return selector().template Type<std::string_view>().Case("foo");
};

template <typename Value>
ns::Int Parse(Value value, USERVER_NAMESPACE::formats::parse::To<ns::Int>) {
value.CheckNotMissing();
value.CheckObjectOrNull();
value.CheckNotMissing();
value.CheckObjectOrNull();

ns::Int res;
ns::Int res;

res.foo =
value["foo"]
.template As<
std::optional<USERVER_NAMESPACE::chaotic::Primitive<int>>>();
res.foo = value["foo"].template As<std::optional<USERVER_NAMESPACE::chaotic::Primitive<int>>>();

USERVER_NAMESPACE::chaotic::ValidateNoAdditionalProperties(
value, kns__Int_PropertiesNames);
USERVER_NAMESPACE::chaotic::ValidateNoAdditionalProperties(value, kns__Int_PropertiesNames);

return res;
return res;
}

} // namespace ns

27 changes: 13 additions & 14 deletions chaotic/golden_tests/output/schemas/oneof/oneof_parsers.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,26 @@

namespace ns {

static constexpr USERVER_NAMESPACE::utils::TrivialSet
kns__OneOf_PropertiesNames = [](auto selector) {
return selector().template Type<std::string_view>().Case("foo");
};
static constexpr USERVER_NAMESPACE::utils::TrivialSet kns__OneOf_PropertiesNames = [](auto selector) {
return selector().template Type<std::string_view>().Case("foo");
};

template <typename Value>
ns::OneOf Parse(Value value, USERVER_NAMESPACE::formats::parse::To<ns::OneOf>) {
value.CheckNotMissing();
value.CheckObjectOrNull();
value.CheckNotMissing();
value.CheckObjectOrNull();

ns::OneOf res;
ns::OneOf res;

res.foo = value["foo"]
.template As<std::optional<USERVER_NAMESPACE::chaotic::Variant<
USERVER_NAMESPACE::chaotic::Primitive<int>,
USERVER_NAMESPACE::chaotic::Primitive<std::string>>>>();
res.foo = value["foo"]
.template As<std::optional<USERVER_NAMESPACE::chaotic::Variant<
USERVER_NAMESPACE::chaotic::Primitive<int>,
USERVER_NAMESPACE::chaotic::Primitive<std::string>>>>();

USERVER_NAMESPACE::chaotic::ValidateNoAdditionalProperties(
value, kns__OneOf_PropertiesNames);
USERVER_NAMESPACE::chaotic::ValidateNoAdditionalProperties(value, kns__OneOf_PropertiesNames);

return res;
return res;
}

} // namespace ns

Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ A Parse(USERVER_NAMESPACE::formats::json::Value json, USERVER_NAMESPACE::formats
return Parse<USERVER_NAMESPACE::formats::json::Value>(json, to);
}

/* Parse(USERVER_NAMESPACE::formats::yaml::Value, To<ns::A>) was not generated:
* ns::A has JSON-specific field "extra" */
/* Parse(USERVER_NAMESPACE::formats::yaml::Value, To<ns::A>) was not generated: ns::A has JSON-specific field "extra" */

/* Parse(USERVER_NAMESPACE::yaml_config::Value, To<ns::A>) was not generated:
* ns::A has JSON-specific field "extra" */
/* Parse(USERVER_NAMESPACE::yaml_config::Value, To<ns::A>) was not generated: ns::A has JSON-specific field "extra" */

USERVER_NAMESPACE::formats::json::Value
Serialize([[maybe_unused]] const ns::A& value, USERVER_NAMESPACE::formats::serialize::To<USERVER_NAMESPACE::formats::json::Value>) {
Expand Down Expand Up @@ -55,11 +53,9 @@ B Parse(USERVER_NAMESPACE::formats::json::Value json, USERVER_NAMESPACE::formats
return Parse<USERVER_NAMESPACE::formats::json::Value>(json, to);
}

/* Parse(USERVER_NAMESPACE::formats::yaml::Value, To<ns::B>) was not generated:
* ns::B has JSON-specific field "extra" */
/* Parse(USERVER_NAMESPACE::formats::yaml::Value, To<ns::B>) was not generated: ns::B has JSON-specific field "extra" */

/* Parse(USERVER_NAMESPACE::yaml_config::Value, To<ns::B>) was not generated:
* ns::B has JSON-specific field "extra" */
/* Parse(USERVER_NAMESPACE::yaml_config::Value, To<ns::B>) was not generated: ns::B has JSON-specific field "extra" */

USERVER_NAMESPACE::formats::json::Value
Serialize([[maybe_unused]] const ns::B& value, USERVER_NAMESPACE::formats::serialize::To<USERVER_NAMESPACE::formats::json::Value>) {
Expand Down Expand Up @@ -90,12 +86,11 @@ Parse(USERVER_NAMESPACE::formats::json::Value json, USERVER_NAMESPACE::formats::
return Parse<USERVER_NAMESPACE::formats::json::Value>(json, to);
}

/* Parse(USERVER_NAMESPACE::formats::yaml::Value, To<ns::OneOfDiscriminator>)
* was not generated: ns::OneOfDiscriminator::Foo has JSON-specific field
* "extra" */
/* Parse(USERVER_NAMESPACE::formats::yaml::Value, To<ns::OneOfDiscriminator>) was not generated:
* ns::OneOfDiscriminator::Foo has JSON-specific field "extra" */

/* Parse(USERVER_NAMESPACE::yaml_config::Value, To<ns::OneOfDiscriminator>) was
* not generated: ns::OneOfDiscriminator::Foo has JSON-specific field "extra" */
/* Parse(USERVER_NAMESPACE::yaml_config::Value, To<ns::OneOfDiscriminator>) was not generated:
* ns::OneOfDiscriminator::Foo has JSON-specific field "extra" */

USERVER_NAMESPACE::formats::json::Value
Serialize([[maybe_unused]] const ns::OneOfDiscriminator& value, USERVER_NAMESPACE::formats::serialize::To<USERVER_NAMESPACE::formats::json::Value>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@ USERVER_NAMESPACE::logging::LogHelper& operator<<(USERVER_NAMESPACE::logging::Lo

A Parse(USERVER_NAMESPACE::formats::json::Value json, USERVER_NAMESPACE::formats::parse::To<ns::A>);

/* Parse(USERVER_NAMESPACE::formats::yaml::Value, To<ns::A>) was not generated:
* ns::A has JSON-specific field "extra" */
/* Parse(USERVER_NAMESPACE::formats::yaml::Value, To<ns::A>) was not generated: ns::A has JSON-specific field "extra" */

/* Parse(USERVER_NAMESPACE::yaml_config::Value, To<ns::A>) was not generated:
* ns::A has JSON-specific field "extra" */
/* Parse(USERVER_NAMESPACE::yaml_config::Value, To<ns::A>) was not generated: ns::A has JSON-specific field "extra" */

USERVER_NAMESPACE::formats::json::Value
Serialize(const ns::A& value, USERVER_NAMESPACE::formats::serialize::To<USERVER_NAMESPACE::formats::json::Value>);
Expand All @@ -48,11 +46,9 @@ USERVER_NAMESPACE::logging::LogHelper& operator<<(USERVER_NAMESPACE::logging::Lo

B Parse(USERVER_NAMESPACE::formats::json::Value json, USERVER_NAMESPACE::formats::parse::To<ns::B>);

/* Parse(USERVER_NAMESPACE::formats::yaml::Value, To<ns::B>) was not generated:
* ns::B has JSON-specific field "extra" */
/* Parse(USERVER_NAMESPACE::formats::yaml::Value, To<ns::B>) was not generated: ns::B has JSON-specific field "extra" */

/* Parse(USERVER_NAMESPACE::yaml_config::Value, To<ns::B>) was not generated:
* ns::B has JSON-specific field "extra" */
/* Parse(USERVER_NAMESPACE::yaml_config::Value, To<ns::B>) was not generated: ns::B has JSON-specific field "extra" */

USERVER_NAMESPACE::formats::json::Value
Serialize(const ns::B& value, USERVER_NAMESPACE::formats::serialize::To<USERVER_NAMESPACE::formats::json::Value>);
Expand All @@ -77,12 +73,11 @@ operator<<(USERVER_NAMESPACE::logging::LogHelper& lh, const ns::OneOfDiscriminat
OneOfDiscriminator
Parse(USERVER_NAMESPACE::formats::json::Value json, USERVER_NAMESPACE::formats::parse::To<ns::OneOfDiscriminator>);

/* Parse(USERVER_NAMESPACE::formats::yaml::Value, To<ns::OneOfDiscriminator>)
* was not generated: ns::OneOfDiscriminator::Foo has JSON-specific field
* "extra" */
/* Parse(USERVER_NAMESPACE::formats::yaml::Value, To<ns::OneOfDiscriminator>) was not generated:
* ns::OneOfDiscriminator::Foo has JSON-specific field "extra" */

/* Parse(USERVER_NAMESPACE::yaml_config::Value, To<ns::OneOfDiscriminator>) was
* not generated: ns::OneOfDiscriminator::Foo has JSON-specific field "extra" */
/* Parse(USERVER_NAMESPACE::yaml_config::Value, To<ns::OneOfDiscriminator>) was not generated:
* ns::OneOfDiscriminator::Foo has JSON-specific field "extra" */

USERVER_NAMESPACE::formats::json::Value
Serialize(const ns::OneOfDiscriminator& value, USERVER_NAMESPACE::formats::serialize::To<USERVER_NAMESPACE::formats::json::Value>);
Expand Down
Loading

0 comments on commit 1f968ab

Please sign in to comment.