-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
db.rs
44 lines (38 loc) · 928 Bytes
/
db.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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
| query db "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
| query db "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" | query db "select * from asdf"
"#
));
assert!(actual.err.contains("can't convert string"));
}