|
|
@ -58,6 +58,7 @@ fn test_limit_offset() {
|
|
|
|
.into_json();
|
|
|
|
.into_json();
|
|
|
|
assert_eq!(res["rows"], json!([]));
|
|
|
|
assert_eq!(res["rows"], json!([]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
fn test_normal_aggr_empty() {
|
|
|
|
fn test_normal_aggr_empty() {
|
|
|
|
let db = new_cozo_mem().unwrap();
|
|
|
|
let db = new_cozo_mem().unwrap();
|
|
|
@ -67,6 +68,7 @@ fn test_normal_aggr_empty() {
|
|
|
|
.rows;
|
|
|
|
.rows;
|
|
|
|
assert_eq!(res, vec![vec![DataValue::from(0)]]);
|
|
|
|
assert_eq!(res, vec![vec![DataValue::from(0)]]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
fn test_meet_aggr_empty() {
|
|
|
|
fn test_meet_aggr_empty() {
|
|
|
|
let db = new_cozo_mem().unwrap();
|
|
|
|
let db = new_cozo_mem().unwrap();
|
|
|
@ -82,6 +84,7 @@ fn test_meet_aggr_empty() {
|
|
|
|
.rows;
|
|
|
|
.rows;
|
|
|
|
assert_eq!(res, vec![vec![DataValue::Null, DataValue::from(0)]]);
|
|
|
|
assert_eq!(res, vec![vec![DataValue::Null, DataValue::from(0)]]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
fn test_layers() {
|
|
|
|
fn test_layers() {
|
|
|
|
let _ = env_logger::builder().is_test(true).try_init();
|
|
|
|
let _ = env_logger::builder().is_test(true).try_init();
|
|
|
@ -101,6 +104,7 @@ fn test_layers() {
|
|
|
|
.rows;
|
|
|
|
.rows;
|
|
|
|
assert_eq!(res[0][0], DataValue::from(21.))
|
|
|
|
assert_eq!(res[0][0], DataValue::from(21.))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
fn test_conditions() {
|
|
|
|
fn test_conditions() {
|
|
|
|
let _ = env_logger::builder().is_test(true).try_init();
|
|
|
|
let _ = env_logger::builder().is_test(true).try_init();
|
|
|
@ -132,6 +136,7 @@ fn test_conditions() {
|
|
|
|
.rows;
|
|
|
|
.rows;
|
|
|
|
assert_eq!(res[0][0], DataValue::from(1.1))
|
|
|
|
assert_eq!(res[0][0], DataValue::from(1.1))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
fn test_classical() {
|
|
|
|
fn test_classical() {
|
|
|
|
let _ = env_logger::builder().is_test(true).try_init();
|
|
|
|
let _ = env_logger::builder().is_test(true).try_init();
|
|
|
@ -183,19 +188,19 @@ fn rm_does_not_need_all_keys() {
|
|
|
|
assert!(db
|
|
|
|
assert!(db
|
|
|
|
.run_script(
|
|
|
|
.run_script(
|
|
|
|
"?[uid, mood] <- [[1, 2]] :put status {uid => mood}",
|
|
|
|
"?[uid, mood] <- [[1, 2]] :put status {uid => mood}",
|
|
|
|
Default::default()
|
|
|
|
Default::default(),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.is_ok());
|
|
|
|
.is_ok());
|
|
|
|
assert!(db
|
|
|
|
assert!(db
|
|
|
|
.run_script(
|
|
|
|
.run_script(
|
|
|
|
"?[uid, mood] <- [[2]] :put status {uid}",
|
|
|
|
"?[uid, mood] <- [[2]] :put status {uid}",
|
|
|
|
Default::default()
|
|
|
|
Default::default(),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.is_err());
|
|
|
|
.is_err());
|
|
|
|
assert!(db
|
|
|
|
assert!(db
|
|
|
|
.run_script(
|
|
|
|
.run_script(
|
|
|
|
"?[uid, mood] <- [[3, 2]] :rm status {uid => mood}",
|
|
|
|
"?[uid, mood] <- [[3, 2]] :rm status {uid => mood}",
|
|
|
|
Default::default()
|
|
|
|
Default::default(),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.is_ok());
|
|
|
|
.is_ok());
|
|
|
|
assert!(db
|
|
|
|
assert!(db
|
|
|
@ -1160,6 +1165,18 @@ fn multi_index_vec() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
|
|
|
fn ensure_not() {
|
|
|
|
|
|
|
|
let db = DbInstance::new("mem", "", "").unwrap();
|
|
|
|
|
|
|
|
db.run_script(r"
|
|
|
|
|
|
|
|
%ignore_error { :create id_alloc{id: Int => next_id: Int, last_id: Int}}
|
|
|
|
|
|
|
|
%ignore_error {
|
|
|
|
|
|
|
|
?[id, next_id, last_id] <- [[0, 1, 1000]];
|
|
|
|
|
|
|
|
:ensure_not id_alloc{id => next_id, last_id}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
", Default::default()).unwrap();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
fn parser_corner_case() {
|
|
|
|
fn parser_corner_case() {
|
|
|
|
let db = DbInstance::new("mem", "", "").unwrap();
|
|
|
|
let db = DbInstance::new("mem", "", "").unwrap();
|
|
|
|