Db commands without DB (#5838)

* database commands without db

* database command tests
This commit is contained in:
Fernando Herrera
2022-06-21 12:14:29 -05:00
committed by GitHub
parent 848ff8453b
commit 7164929c61
33 changed files with 2007 additions and 529 deletions

View File

@ -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"
"#
));