Skip to content

[test] apply the new test style to common-datablocks #2748

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions common/datablocks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ license = "Apache-2.0"
publish = false
edition = "2021"

[lib]
doctest = false
test = false

[dependencies] # In alphabetical order
# Workspace dependencies
common-arrow = {path = "../arrow"}
Expand Down
17 changes: 0 additions & 17 deletions common/datablocks/src/kernels/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#[cfg(test)]
mod data_block_concat_test;
#[cfg(test)]
mod data_block_filter_test;
#[cfg(test)]
mod data_block_group_by_hash_test;
#[cfg(test)]
mod data_block_group_by_test;
#[cfg(test)]
mod data_block_scatter_test;
#[cfg(test)]
mod data_block_slice_test;
#[cfg(test)]
mod data_block_sort_test;
#[cfg(test)]
mod data_block_take_test;

mod data_block_concat;
mod data_block_filter;
mod data_block_group_by;
Expand Down
3 changes: 0 additions & 3 deletions common/datablocks/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@

#![feature(hash_raw_entry)]

#[cfg(test)]
mod data_block_test;

mod data_block;
mod data_block_debug;
mod kernels;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use common_datablocks::DataBlock;
use common_datavalues::prelude::*;
use common_exception::Result;
use pretty_assertions::assert_eq;

use crate::DataBlock;

#[test]
fn test_data_block() -> Result<()> {
let schema = DataSchemaRefExt::create(vec![DataField::new("a", DataType::Int64, false)]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use common_datablocks::*;
use common_datavalues::prelude::*;
use common_datavalues::series::Series;
use common_datavalues::series::SeriesFrom;
use common_exception::Result;

use crate::*;

#[test]
fn test_data_block_concat() -> Result<()> {
let schema = DataSchemaRefExt::create(vec![
Expand Down Expand Up @@ -59,6 +58,6 @@ fn test_data_block_concat() -> Result<()> {
"| 9 | b3 |",
"+---+----+",
];
crate::assert_blocks_eq(expected, &[results]);
common_datablocks::assert_blocks_eq(expected, &[results]);
Ok(())
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use common_datablocks::DataBlock;
use common_datavalues::columns::DataColumn;
use common_datavalues::prelude::SeriesFrom;
use common_datavalues::series::Series;
Expand All @@ -21,8 +22,6 @@ use common_datavalues::DataType;
use common_datavalues::DataValue;
use common_exception::Result;

use crate::DataBlock;

#[test]
fn test_filter_non_const_data_block() -> Result<()> {
let schema = DataSchemaRefExt::create(vec![
Expand All @@ -38,7 +37,7 @@ fn test_filter_non_const_data_block() -> Result<()> {
let predicate = Series::new(vec![true, false, true, true, false, false]);
let block = DataBlock::filter_block(&block, predicate)?;

crate::assert_blocks_eq(
common_datablocks::assert_blocks_eq(
vec![
"+---+----+",
"| a | b |",
Expand Down Expand Up @@ -69,9 +68,10 @@ fn test_filter_all_false_data_block() -> Result<()> {
let predicate = Series::new(vec![false, false, false, false, false, false]);
let block = DataBlock::filter_block(&block, predicate)?;

crate::assert_blocks_eq(vec!["+---+---+", "| a | b |", "+---+---+", "+---+---+"], &[
block,
]);
common_datablocks::assert_blocks_eq(
vec!["+---+---+", "| a | b |", "+---+---+", "+---+---+"],
&[block],
);

Ok(())
}
Expand All @@ -91,7 +91,7 @@ fn test_filter_const_data_block() -> Result<()> {
let predicate = Series::new(vec![true, false, true, true, false, false]);
let block = DataBlock::filter_block(&block, predicate)?;

crate::assert_blocks_eq(
common_datablocks::assert_blocks_eq(
vec![
"+---+----+",
"| a | b |",
Expand Down Expand Up @@ -122,7 +122,7 @@ fn test_filter_all_const_data_block() -> Result<()> {
let predicate = Series::new(vec![true, false, true, true, false, false]);
let block = DataBlock::filter_block(&block, predicate)?;

crate::assert_blocks_eq(
common_datablocks::assert_blocks_eq(
vec![
"+---+----+",
"| a | b |",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use common_datablocks::*;
use common_datavalues::prelude::*;
use common_exception::Result;

use crate::*;

#[test]
fn test_data_block_group_by() -> Result<()> {
let schema = DataSchemaRefExt::create(vec![
Expand All @@ -41,7 +40,7 @@ fn test_data_block_group_by() -> Result<()> {
"| 3 | x3 |",
"+---+----+",
];
crate::assert_blocks_sorted_eq(expected, &[block]);
common_datablocks::assert_blocks_sorted_eq(expected, &[block]);
}
2 => {
let expected = vec![
Expand All @@ -52,7 +51,7 @@ fn test_data_block_group_by() -> Result<()> {
"| 2 | x2 |",
"+---+----+",
];
crate::assert_blocks_sorted_eq(expected, &[block]);
common_datablocks::assert_blocks_sorted_eq(expected, &[block]);
}
3 => {
let expected = vec![
Expand All @@ -64,7 +63,7 @@ fn test_data_block_group_by() -> Result<()> {
"| 1 | x1 |",
"+---+----+",
];
crate::assert_blocks_sorted_eq(expected, &[block]);
common_datablocks::assert_blocks_sorted_eq(expected, &[block]);
}
_ => unreachable!(),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use common_datablocks::*;
use common_datavalues::prelude::*;
use common_exception::Result;

use crate::*;

#[test]
fn test_data_block_group_by_hash() -> Result<()> {
let schema = DataSchemaRefExt::create(vec![
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use common_datablocks::*;
use common_datavalues::prelude::*;
use common_exception::Result;

use crate::*;

#[test]
fn test_data_block_scatter() -> Result<()> {
let schema = DataSchemaRefExt::create(vec![
Expand Down Expand Up @@ -46,7 +45,7 @@ fn test_data_block_scatter() -> Result<()> {
"| 2 | 2 |",
"+---+---+",
];
crate::assert_blocks_eq(expected, &scattered);
common_datablocks::assert_blocks_eq(expected, &scattered);

Ok(())
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use common_datablocks::*;
use common_datavalues::prelude::*;
use common_exception::Result;

use crate::*;

#[test]
fn test_data_block_slice() -> Result<()> {
let schema = DataSchemaRefExt::create(vec![
Expand All @@ -43,6 +42,6 @@ fn test_data_block_slice() -> Result<()> {
"| 5 | 5 |",
"+---+---+",
];
crate::assert_blocks_eq(expected, &sliced);
common_datablocks::assert_blocks_eq(expected, &sliced);
Ok(())
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use common_datablocks::*;
use common_datavalues::prelude::*;
use common_exception::Result;

use crate::*;

#[test]
fn test_data_block_sort() -> Result<()> {
let schema = DataSchemaRefExt::create(vec![
Expand Down Expand Up @@ -47,7 +46,7 @@ fn test_data_block_sort() -> Result<()> {
"| 3 | b3 |",
"+---+----+",
];
crate::assert_blocks_eq(expected, &[results]);
common_datablocks::assert_blocks_eq(expected, &[results]);
}

{
Expand All @@ -68,7 +67,7 @@ fn test_data_block_sort() -> Result<()> {
"| 4 | b2 |",
"+---+----+",
];
crate::assert_blocks_eq(expected, &[results]);
common_datablocks::assert_blocks_eq(expected, &[results]);
}
Ok(())
}
Expand Down Expand Up @@ -112,7 +111,7 @@ fn test_data_block_merge_sort() -> Result<()> {
"| 7 | b3 |",
"+---+----+",
];
crate::assert_blocks_eq(expected, &[results]);
common_datablocks::assert_blocks_eq(expected, &[results]);
}

Ok(())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use common_datablocks::*;
use common_datavalues::prelude::*;
use common_exception::Result;

use crate::*;

#[test]
fn test_data_block_take() -> Result<()> {
let schema = DataSchemaRefExt::create(vec![
Expand All @@ -40,7 +39,7 @@ fn test_data_block_take() -> Result<()> {
"| 3 | b3 |",
"+---+----+",
];
crate::assert_blocks_eq(expected, &[take]);
common_datablocks::assert_blocks_eq(expected, &[take]);

Ok(())
}
22 changes: 22 additions & 0 deletions common/datablocks/tests/it/kernels/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright 2020 Datafuse Labs.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

mod data_block_concat;
mod data_block_filter;
mod data_block_group_by;
mod data_block_group_by_hash;
mod data_block_scatter;
mod data_block_slice;
mod data_block_sort;
mod data_block_take;
16 changes: 16 additions & 0 deletions common/datablocks/tests/it/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright 2020 Datafuse Labs.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

mod data_block;
mod kernels;