Skip to content

Commit

Permalink
fix(test): fix fields derive unit test (#16406)
Browse files Browse the repository at this point in the history
Signed-off-by: Richard Chien <[email protected]>
Signed-off-by: Bugen Zhao <[email protected]>
Co-authored-by: Bugen Zhao <[email protected]>
  • Loading branch information
stdrc and BugenZhao authored Apr 23, 2024
1 parent 1657ab0 commit 76fea70
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/common/fields-derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ syn = { version = "2", features = ["full", "extra-traits"] }
[dev-dependencies]
expect-test = "1"
indoc = "2"
prettyplease = "0.2"
prettyplease = { version = "0.2", features = ["verbatim"] }
15 changes: 10 additions & 5 deletions src/common/fields-derive/src/gen/test_empty_pk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,21 @@ impl ::risingwave_common::types::Fields for Data {
const PRIMARY_KEY: Option<&'static [usize]> = Some(&[]);
fn fields() -> Vec<(&'static str, ::risingwave_common::types::DataType)> {
vec![
("v1", < i16 as ::risingwave_common::types::WithDataType >
::default_data_type()), ("v2", < String as
::risingwave_common::types::WithDataType > ::default_data_type())
(
"v1",
<i16 as ::risingwave_common::types::WithDataType>::default_data_type(),
),
(
"v2",
<String as ::risingwave_common::types::WithDataType>::default_data_type(),
),
]
}
fn into_owned_row(self) -> ::risingwave_common::row::OwnedRow {
::risingwave_common::row::OwnedRow::new(
vec![
::risingwave_common::types::ToOwnedDatum::to_owned_datum(self.v1),
::risingwave_common::types::ToOwnedDatum::to_owned_datum(self.v2)
::risingwave_common::types::ToOwnedDatum::to_owned_datum(self.v2),
],
)
}
Expand All @@ -21,7 +26,7 @@ impl From<Data> for ::risingwave_common::types::ScalarImpl {
::risingwave_common::types::StructValue::new(
vec![
::risingwave_common::types::ToOwnedDatum::to_owned_datum(v.v1),
::risingwave_common::types::ToOwnedDatum::to_owned_datum(v.v2)
::risingwave_common::types::ToOwnedDatum::to_owned_datum(v.v2),
],
)
.into()
Expand Down
15 changes: 10 additions & 5 deletions src/common/fields-derive/src/gen/test_no_pk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,21 @@ impl ::risingwave_common::types::Fields for Data {
const PRIMARY_KEY: Option<&'static [usize]> = None;
fn fields() -> Vec<(&'static str, ::risingwave_common::types::DataType)> {
vec![
("v1", < i16 as ::risingwave_common::types::WithDataType >
::default_data_type()), ("v2", < String as
::risingwave_common::types::WithDataType > ::default_data_type())
(
"v1",
<i16 as ::risingwave_common::types::WithDataType>::default_data_type(),
),
(
"v2",
<String as ::risingwave_common::types::WithDataType>::default_data_type(),
),
]
}
fn into_owned_row(self) -> ::risingwave_common::row::OwnedRow {
::risingwave_common::row::OwnedRow::new(
vec![
::risingwave_common::types::ToOwnedDatum::to_owned_datum(self.v1),
::risingwave_common::types::ToOwnedDatum::to_owned_datum(self.v2)
::risingwave_common::types::ToOwnedDatum::to_owned_datum(self.v2),
],
)
}
Expand All @@ -21,7 +26,7 @@ impl From<Data> for ::risingwave_common::types::ScalarImpl {
::risingwave_common::types::StructValue::new(
vec![
::risingwave_common::types::ToOwnedDatum::to_owned_datum(v.v1),
::risingwave_common::types::ToOwnedDatum::to_owned_datum(v.v2)
::risingwave_common::types::ToOwnedDatum::to_owned_datum(v.v2),
],
)
.into()
Expand Down
31 changes: 22 additions & 9 deletions src/common/fields-derive/src/gen/test_output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,26 @@ impl ::risingwave_common::types::Fields for Data {
const PRIMARY_KEY: Option<&'static [usize]> = Some(&[1usize, 0usize]);
fn fields() -> Vec<(&'static str, ::risingwave_common::types::DataType)> {
vec![
("v1", < i16 as ::risingwave_common::types::WithDataType >
::default_data_type()), ("v2", < std::primitive::i32 as
::risingwave_common::types::WithDataType > ::default_data_type()), ("v3", <
bool as ::risingwave_common::types::WithDataType > ::default_data_type()),
("v4", < Serial as ::risingwave_common::types::WithDataType >
::default_data_type()), ("type", < i32 as
::risingwave_common::types::WithDataType > ::default_data_type())
(
"v1",
<i16 as ::risingwave_common::types::WithDataType>::default_data_type(),
),
(
"v2",
<std::primitive::i32 as ::risingwave_common::types::WithDataType>::default_data_type(),
),
(
"v3",
<bool as ::risingwave_common::types::WithDataType>::default_data_type(),
),
(
"v4",
<Serial as ::risingwave_common::types::WithDataType>::default_data_type(),
),
(
"type",
<i32 as ::risingwave_common::types::WithDataType>::default_data_type(),
),
]
}
fn into_owned_row(self) -> ::risingwave_common::row::OwnedRow {
Expand All @@ -18,7 +31,7 @@ impl ::risingwave_common::types::Fields for Data {
::risingwave_common::types::ToOwnedDatum::to_owned_datum(self.v2),
::risingwave_common::types::ToOwnedDatum::to_owned_datum(self.v3),
::risingwave_common::types::ToOwnedDatum::to_owned_datum(self.v4),
::risingwave_common::types::ToOwnedDatum::to_owned_datum(self.r#type)
::risingwave_common::types::ToOwnedDatum::to_owned_datum(self.r#type),
],
)
}
Expand All @@ -31,7 +44,7 @@ impl From<Data> for ::risingwave_common::types::ScalarImpl {
::risingwave_common::types::ToOwnedDatum::to_owned_datum(v.v2),
::risingwave_common::types::ToOwnedDatum::to_owned_datum(v.v3),
::risingwave_common::types::ToOwnedDatum::to_owned_datum(v.v4),
::risingwave_common::types::ToOwnedDatum::to_owned_datum(v.r#type)
::risingwave_common::types::ToOwnedDatum::to_owned_datum(v.r#type),
],
)
.into()
Expand Down

0 comments on commit 76fea70

Please sign in to comment.