mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 06:30:08 +02:00
Db commands without DB (#5838)
* database commands without db * database command tests
This commit is contained in:
@ -1,12 +1,14 @@
|
||||
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
|
||||
| db query "select * from strings"
|
||||
| into db
|
||||
| query "select * from strings"
|
||||
| where x =~ ell
|
||||
| length
|
||||
"#
|
||||
@ -15,25 +17,28 @@ fn can_query_single_table() {
|
||||
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
|
||||
| db query "select *asdfasdf"
|
||||
| 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" | db query "select * from asdf"
|
||||
"foo" | into db | query "select * from asdf"
|
||||
"#
|
||||
));
|
||||
|
||||
|
Reference in New Issue
Block a user