mirror of
https://github.com/nushell/nushell.git
synced 2024-12-26 17:09:06 +01:00
7164929c61
* database commands without db * database command tests
47 lines
973 B
Rust
47 lines
973 B
Rust
use nu_test_support::{nu, pipeline};
|
|
|
|
#[cfg(feature = "database")]
|
|
#[test]
|
|
fn can_query_single_table() {
|
|
let actual = nu!(
|
|
cwd: "tests/fixtures/formats", pipeline(
|
|
r#"
|
|
open sample.db
|
|
| into db
|
|
| query "select * from strings"
|
|
| where x =~ ell
|
|
| length
|
|
"#
|
|
));
|
|
|
|
assert_eq!(actual.out, "4");
|
|
}
|
|
|
|
#[cfg(feature = "database")]
|
|
#[test]
|
|
fn invalid_sql_fails() {
|
|
let actual = nu!(
|
|
cwd: "tests/fixtures/formats", pipeline(
|
|
r#"
|
|
open sample.db
|
|
| into db
|
|
| query "select *asdfasdf"
|
|
"#
|
|
));
|
|
|
|
assert!(actual.err.contains("syntax error"));
|
|
}
|
|
|
|
#[cfg(feature = "database")]
|
|
#[test]
|
|
fn invalid_input_fails() {
|
|
let actual = nu!(
|
|
cwd: "tests/fixtures/formats", pipeline(
|
|
r#"
|
|
"foo" | into db | query "select * from asdf"
|
|
"#
|
|
));
|
|
|
|
assert!(actual.err.contains("can't convert string"));
|
|
}
|