mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 14:40:06 +02:00
SQLite overhaul: custom value, query db
command (#5247)
Clean up query errors
This commit is contained in:
47
crates/nu-command/tests/commands/query/db.rs
Normal file
47
crates/nu-command/tests/commands/query/db.rs
Normal file
@ -0,0 +1,47 @@
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
|
||||
fn can_query_single_table() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
open sample.db
|
||||
| query db "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
|
||||
| query db "select *asdfasdf"
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(actual.err.contains("syntax error"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn invalid_input_fails() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
"foo" | query db "select * from asdf"
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(actual.err.contains("pipeline_mismatch"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn scratch() {
|
||||
assert!(true);
|
||||
}
|
1
crates/nu-command/tests/commands/query/mod.rs
Normal file
1
crates/nu-command/tests/commands/query/mod.rs
Normal file
@ -0,0 +1 @@
|
||||
mod db;
|
Reference in New Issue
Block a user