nushell/crates/nu-command/tests/commands/query/db.rs
Fernando Herrera e94d13da1b
Database commands (#5307)
* database commands

* db commands

* filesystem opens sqlite file

* clippy error

* corrected error in ci file

* removes matrix flag from ci

* flax matrix for clippy

* add conditional compile for tests

* add conditional compile for tests

* correct order of command

* correct error msg

* correct typo
2022-04-24 10:29:21 +01:00

42 lines
841 B
Rust

use nu_test_support::{nu, pipeline};
#[test]
fn can_query_single_table() {
let actual = nu!(
cwd: "tests/fixtures/formats", pipeline(
r#"
open sample.db
| db query "select * from strings"
| where x =~ ell
| length
"#
));
assert_eq!(actual.out, "4");
}
#[test]
fn invalid_sql_fails() {
let actual = nu!(
cwd: "tests/fixtures/formats", pipeline(
r#"
open sample.db
| db query "select *asdfasdf"
"#
));
assert!(actual.err.contains("syntax error"));
}
#[test]
fn invalid_input_fails() {
let actual = nu!(
cwd: "tests/fixtures/formats", pipeline(
r#"
"foo" | db query "select * from asdf"
"#
));
assert!(actual.err.contains("can't convert string"));
}