Skip to content

Commit f3f7d97

Browse files
committed
[test] apply the new test style to common_functions
Signed-off-by: Chojan Shang <[email protected]>
1 parent 4464dfb commit f3f7d97

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+144
-117
lines changed

common/functions/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ license = "Apache-2.0"
66
publish = false
77
edition = "2021"
88

9+
[lib]
10+
doctest = false
11+
test = false
12+
913
[dependencies] # In alphabetical order
1014
# Workspace dependencies
1115
common-arrow = {path = "../arrow"}

common/functions/src/aggregates/mod.rs

-5
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#[cfg(test)]
16-
mod aggregate_combinator_test;
17-
#[cfg(test)]
18-
mod aggregate_function_test;
19-
2015
mod aggregate_arg_min_max;
2116
mod aggregate_avg;
2217
mod aggregate_combinator_distinct;

common/functions/src/scalars/arithmetics/mod.rs

-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#[cfg(test)]
16-
mod arithmetic_test;
17-
1815
mod arithmetic;
1916
mod arithmetic_div;
2017
mod arithmetic_minus;

common/functions/src/scalars/comparisons/mod.rs

-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#[cfg(test)]
16-
mod comparison_test;
17-
1815
mod comparison;
1916
mod comparison_eq;
2017
mod comparison_gt;

common/functions/src/scalars/conditionals/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414

1515
mod conditional;
1616
mod r#if;
17-
#[cfg(test)]
18-
mod if_test;
1917

2018
pub use conditional::ConditionalFunction;
2119
pub use r#if::IfFunction;

common/functions/src/scalars/dates/mod.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,6 @@
1313
// limitations under the License.
1414

1515
mod date;
16-
#[cfg(test)]
17-
mod date_function_test;
18-
#[cfg(test)]
19-
mod date_test;
20-
21-
#[cfg(test)]
22-
mod interval_function_test;
23-
2416
mod interval_function;
2517
mod now;
2618
mod number_function;
@@ -38,6 +30,7 @@ pub use number_function::ToDayOfWeekFunction;
3830
pub use number_function::ToDayOfYearFunction;
3931
pub use number_function::ToHourFunction;
4032
pub use number_function::ToMinuteFunction;
33+
pub use number_function::ToMondayFunction;
4134
pub use number_function::ToMonthFunction;
4235
pub use number_function::ToSecondFunction;
4336
pub use number_function::ToStartOfISOYearFunction;

common/functions/src/scalars/expressions/mod.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,8 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#[cfg(test)]
16-
mod cast_test;
17-
mod expression;
18-
1915
mod cast;
16+
mod expression;
2017

2118
pub use cast::CastFunction;
2219
pub use expression::ToCastFunction;

common/functions/src/scalars/hashes/mod.rs

-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#[cfg(test)]
16-
mod siphash_test;
17-
1815
mod hash;
1916
mod siphash;
2017

common/functions/src/scalars/logics/mod.rs

-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#[cfg(test)]
16-
mod logic_test;
17-
1815
mod logic;
1916
mod logic_and;
2017
mod logic_not;

common/functions/src/scalars/maths/mod.rs

-9
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,6 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#[cfg(test)]
16-
mod abs_test;
17-
#[cfg(test)]
18-
mod crc32_test;
19-
#[cfg(test)]
20-
mod pi_test;
21-
#[cfg(test)]
22-
mod trigonometric_test;
23-
2415
mod abs;
2516
mod crc32;
2617
mod math;

common/functions/src/scalars/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ mod expressions;
2020
mod function;
2121
mod function_alias;
2222
mod function_column;
23-
#[cfg(test)]
24-
mod function_column_test;
2523
mod function_factory;
2624
mod function_literal;
2725
mod hashes;

common/functions/src/scalars/nullables/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
mod is_not_null;
1616
mod is_null;
1717
mod nullable;
18-
#[cfg(test)]
19-
mod nullable_test;
2018

2119
pub use is_not_null::IsNotNullFunction;
2220
pub use is_null::IsNullFunction;

common/functions/src/scalars/others/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
14-
#[cfg(test)]
15-
mod running_difference_function_test;
1614

1715
mod other;
1816
mod running_difference_function;
17+
1918
pub use other::OtherFunction;
2019
pub use running_difference_function::RunningDifferenceFunction;

common/functions/src/scalars/strings/mod.rs

-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#[cfg(test)]
16-
mod substring_test;
17-
1815
mod string;
1916
mod substring;
2017

common/functions/src/scalars/udfs/mod.rs

-9
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,6 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#[cfg(test)]
16-
mod database_test;
17-
#[cfg(test)]
18-
mod to_type_name_test;
19-
#[cfg(test)]
20-
mod udf_example_test;
21-
#[cfg(test)]
22-
mod version_test;
23-
2415
mod crash_me;
2516
mod database;
2617
mod exists;

common/functions/src/aggregates/aggregate_combinator_test.rs renamed to common/functions/tests/it/aggregates/aggregate_combinator.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@
1515
use bumpalo::Bump;
1616
use common_datavalues::prelude::*;
1717
use common_exception::Result;
18+
use common_functions::aggregates::AggregateFunctionFactory;
1819
use pretty_assertions::assert_eq;
1920

20-
use crate::aggregates::aggregate_function_factory::AggregateFunctionFactory;
21-
2221
#[test]
2322
fn test_aggregate_combinator_function() -> Result<()> {
2423
struct Test {

common/functions/src/aggregates/aggregate_function_test.rs renamed to common/functions/tests/it/aggregates/aggregate_function.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@
1515
use bumpalo::Bump;
1616
use common_datavalues::prelude::*;
1717
use common_exception::Result;
18+
use common_functions::aggregates::*;
1819
use float_cmp::approx_eq;
1920
use pretty_assertions::assert_eq;
2021

21-
use crate::aggregates::*;
22-
2322
#[test]
2423
fn test_aggregate_function() -> Result<()> {
2524
struct Test {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2020 Datafuse Labs.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
mod aggregate_combinator;
16+
mod aggregate_function;

common/functions/tests/it/main.rs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2020 Datafuse Labs.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
mod aggregates;
16+
mod scalars;

common/functions/src/scalars/arithmetics/arithmetic_test.rs renamed to common/functions/tests/it/scalars/arithmetic.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@
1515
use common_datavalues::chrono;
1616
use common_datavalues::prelude::*;
1717
use common_exception::Result;
18+
use common_functions::scalars::*;
1819
use pretty_assertions::assert_eq;
1920

20-
use crate::scalars::*;
21-
2221
#[test]
2322
fn test_arithmetic_function() -> Result<()> {
2423
#[allow(dead_code)]

common/functions/src/scalars/comparisons/comparison_test.rs renamed to common/functions/tests/it/scalars/comparison.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@
1414

1515
use common_datavalues::prelude::*;
1616
use common_exception::Result;
17+
use common_functions::scalars::*;
1718
use pretty_assertions::assert_eq;
1819

19-
use crate::scalars::*;
20-
2120
#[test]
2221
fn test_comparison_function() -> Result<()> {
2322
#[allow(dead_code)]

common/functions/src/scalars/conditionals/if_test.rs renamed to common/functions/tests/it/scalars/conditional.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@
1515
use common_datavalues::prelude::*;
1616
use common_datavalues::DataType;
1717
use common_exception::Result;
18+
use common_functions::scalars::*;
1819
use pretty_assertions::assert_eq;
1920

20-
use crate::scalars::*;
21-
2221
#[test]
2322
fn test_if_function() -> Result<()> {
2423
#[allow(dead_code)]

common/functions/src/scalars/dates/date_test.rs renamed to common/functions/tests/it/scalars/dates/date.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,12 @@
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
14+
1415
use common_datavalues::prelude::*;
1516
use common_exception::Result;
17+
use common_functions::scalars::*;
1618
use pretty_assertions::assert_eq;
1719

18-
use super::RoundFunction;
19-
use crate::scalars::*;
20-
2120
#[allow(dead_code)]
2221
struct Test {
2322
name: &'static str,

common/functions/src/scalars/dates/date_function_test.rs renamed to common/functions/tests/it/scalars/dates/date_function.rs

+1-13
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,7 @@
1414

1515
use common_datavalues::prelude::*;
1616
use common_exception::Result;
17-
18-
use crate::scalars::dates::number_function::ToDayOfMonthFunction;
19-
use crate::scalars::dates::number_function::ToDayOfWeekFunction;
20-
use crate::scalars::dates::number_function::ToDayOfYearFunction;
21-
use crate::scalars::dates::number_function::ToMinuteFunction;
22-
use crate::scalars::dates::number_function::ToMondayFunction;
23-
use crate::scalars::dates::number_function::ToMonthFunction;
24-
use crate::scalars::Function;
25-
use crate::scalars::ToHourFunction;
26-
use crate::scalars::ToSecondFunction;
27-
use crate::scalars::ToYYYYMMDDFunction;
28-
use crate::scalars::ToYYYYMMDDhhmmssFunction;
29-
use crate::scalars::ToYYYYMMFunction;
17+
use common_functions::scalars::*;
3018

3119
#[allow(dead_code)]
3220
struct Test {

common/functions/src/scalars/dates/interval_function_test.rs renamed to common/functions/tests/it/scalars/dates/interval_function.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ use common_datablocks::DataBlock;
1616
use common_datavalues::chrono::DateTime;
1717
use common_datavalues::prelude::*;
1818
use common_exception::Result;
19-
20-
use crate::scalars::MonthsArithmeticFunction;
21-
use crate::scalars::SecondsArithmeticFunction;
19+
use common_functions::scalars::MonthsArithmeticFunction;
20+
use common_functions::scalars::SecondsArithmeticFunction;
2221

2322
#[test]
2423
fn test_add_months() -> Result<()> {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2020 Datafuse Labs.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
mod date;
16+
mod date_function;
17+
mod interval_function;

common/functions/src/scalars/expressions/cast_test.rs renamed to common/functions/tests/it/scalars/expression.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@
1414

1515
use common_datavalues::prelude::*;
1616
use common_exception::Result;
17+
use common_functions::scalars::*;
1718
use pretty_assertions::assert_eq;
1819

19-
use crate::scalars::*;
20-
2120
#[test]
2221
fn test_cast_function() -> Result<()> {
2322
#[allow(dead_code)]

common/functions/src/scalars/function_column_test.rs renamed to common/functions/tests/it/scalars/function_column.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
use common_datablocks::*;
1616
use common_datavalues::prelude::*;
1717
use common_exception::Result;
18-
19-
use crate::scalars::*;
18+
use common_functions::scalars::*;
2019

2120
#[test]
2221
fn test_column_function() -> Result<()> {

common/functions/src/scalars/hashes/siphash_test.rs renamed to common/functions/tests/it/scalars/hash.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
use common_datavalues::columns::DataColumn;
1616
use common_datavalues::prelude::*;
1717
use common_exception::Result;
18-
19-
use crate::scalars::SipHashFunction;
18+
use common_functions::scalars::SipHashFunction;
2019

2120
#[test]
2221
fn test_siphash_function() -> Result<()> {

common/functions/src/scalars/logics/logic_test.rs renamed to common/functions/tests/it/scalars/logic.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@
1414

1515
use common_datavalues::prelude::*;
1616
use common_exception::Result;
17+
use common_functions::scalars::*;
1718
use pretty_assertions::assert_eq;
1819

19-
use crate::scalars::*;
20-
2120
#[test]
2221
fn test_logic_function() -> Result<()> {
2322
#[allow(dead_code)]

common/functions/src/scalars/maths/abs_test.rs renamed to common/functions/tests/it/scalars/maths/abs.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
use common_datavalues::prelude::*;
1616
use common_exception::ErrorCode;
1717
use common_exception::Result;
18-
19-
use crate::scalars::*;
18+
use common_functions::scalars::*;
2019

2120
#[test]
2221
fn test_abs_function() -> Result<()> {

0 commit comments

Comments
 (0)