datafusion-sqlparse/tests/test_utils/mod.rs
Nickolay Ponomarev 4128dfe1db Introduce tests/test_utils/mod.rs and use it consistently
To share helper macros between various tests/* we added a new module
(tests/macros/mod.rs). This made the prologue to be used in tests quite
long and a little weird:
```
#[macro_use]
#[path = "macros/mod.rs"]
mod macros;
use sqlparser::test_utils::*;
```

This simplifies it to:
```
#[macro_use]
mod test_utils;
use test_utils::*;
```
- and switches all existing tests to the new prologue simultaneously...

...while fixing a few other inconsistencies and adding a few comments
about the way `test_utils` work.
2020-10-12 06:52:00 +03:00

34 lines
1.4 KiB
Rust

// 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.
// Re-export everything from `src/test_utils.rs`.
pub use sqlparser::test_utils::*;
// For the test-only macros we take a different approach of keeping them here
// rather than in the library crate.
//
// This is because we don't need any of them to be shared between the
// integration tests (i.e. `tests/*`) and the unit tests (i.e. `src/*`),
// but also because Rust doesn't scope macros to a particular module
// (and while we export internal helpers as sqlparser::test_utils::<...>,
// expecting our users to abstain from relying on them, exporting internal
// macros at the top level, like `sqlparser::nest` was deemed too confusing).
#[macro_export]
macro_rules! nest {
($base:expr $(, $join:expr)*) => {
TableFactor::NestedJoin(Box::new(TableWithJoins {
relation: $base,
joins: vec![$(join($join)),*]
}))
};
}