mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-20 15:35:29 +01:00
Fix tests in csv extension to adapt to new API
This commit is contained in:
@@ -221,7 +221,7 @@ impl VTabModule for CsvVTabModule {
|
||||
sql.push_str(", ");
|
||||
}
|
||||
}
|
||||
sql.push_str(")");
|
||||
sql.push(')');
|
||||
schema = Some(sql);
|
||||
}
|
||||
|
||||
@@ -456,7 +456,7 @@ mod tests {
|
||||
&format!("filename={}", file.path().to_string_lossy()),
|
||||
"header=true",
|
||||
]);
|
||||
let cursor = table.open().unwrap();
|
||||
let cursor = table.open(None).unwrap();
|
||||
let rows = read_rows(cursor, 2);
|
||||
assert_eq!(
|
||||
rows,
|
||||
@@ -470,7 +470,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_data_with_header() {
|
||||
let table = new_table(vec!["data=id,name\n1,Alice\n2,Bob\n", "header=true"]);
|
||||
let cursor = table.open().unwrap();
|
||||
let cursor = table.open(None).unwrap();
|
||||
let rows = read_rows(cursor, 2);
|
||||
assert_eq!(
|
||||
rows,
|
||||
@@ -488,7 +488,7 @@ mod tests {
|
||||
&format!("filename={}", file.path().to_string_lossy()),
|
||||
"header=false",
|
||||
]);
|
||||
let cursor = table.open().unwrap();
|
||||
let cursor = table.open(None).unwrap();
|
||||
let rows = read_rows(cursor, 2);
|
||||
assert_eq!(
|
||||
rows,
|
||||
@@ -502,7 +502,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_data_without_header() {
|
||||
let table = new_table(vec!["data=1,Alice\n2,Bob\n", "header=false"]);
|
||||
let cursor = table.open().unwrap();
|
||||
let cursor = table.open(None).unwrap();
|
||||
let rows = read_rows(cursor, 2);
|
||||
assert_eq!(
|
||||
rows,
|
||||
@@ -520,7 +520,7 @@ mod tests {
|
||||
&format!("filename={}", file.path().to_string_lossy()),
|
||||
"header=true",
|
||||
]);
|
||||
let cursor = table.open().unwrap();
|
||||
let cursor = table.open(None).unwrap();
|
||||
let rows = read_rows(cursor, 2);
|
||||
assert!(rows.is_empty());
|
||||
}
|
||||
@@ -528,7 +528,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_empty_data_with_header() {
|
||||
let table = new_table(vec!["data=id,name\n", "header=true"]);
|
||||
let cursor = table.open().unwrap();
|
||||
let cursor = table.open(None).unwrap();
|
||||
let rows = read_rows(cursor, 2);
|
||||
assert!(rows.is_empty());
|
||||
}
|
||||
@@ -541,7 +541,7 @@ mod tests {
|
||||
"header=false",
|
||||
])
|
||||
.unwrap();
|
||||
let cursor = table.open().unwrap();
|
||||
let cursor = table.open(None).unwrap();
|
||||
let rows = read_rows(cursor, 2);
|
||||
assert!(rows.is_empty());
|
||||
assert_eq!(schema, "CREATE TABLE x(\"c0\" TEXT)");
|
||||
@@ -550,7 +550,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_empty_data_no_header() {
|
||||
let (schema, table) = try_new_table(vec!["data=", "header=false"]).unwrap();
|
||||
let cursor = table.open().unwrap();
|
||||
let cursor = table.open(None).unwrap();
|
||||
let rows = read_rows(cursor, 2);
|
||||
assert!(rows.is_empty());
|
||||
assert_eq!(schema, "CREATE TABLE x(\"c0\" TEXT)");
|
||||
@@ -564,7 +564,7 @@ mod tests {
|
||||
"header=true",
|
||||
])
|
||||
.unwrap();
|
||||
let cursor = table.open().unwrap();
|
||||
let cursor = table.open(None).unwrap();
|
||||
let rows = read_rows(cursor, 2);
|
||||
assert!(rows.is_empty());
|
||||
assert_eq!(schema, "CREATE TABLE x(\"(NULL)\" TEXT)");
|
||||
@@ -573,7 +573,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_empty_data_with_header_enabled() {
|
||||
let (schema, table) = try_new_table(vec!["data=", "header=true"]).unwrap();
|
||||
let cursor = table.open().unwrap();
|
||||
let cursor = table.open(None).unwrap();
|
||||
let rows = read_rows(cursor, 2);
|
||||
assert!(rows.is_empty());
|
||||
assert_eq!(schema, "CREATE TABLE x(\"(NULL)\" TEXT)");
|
||||
@@ -586,7 +586,7 @@ mod tests {
|
||||
&format!("filename={}", file.path().to_string_lossy()),
|
||||
"header=true",
|
||||
]);
|
||||
let cursor = table.open().unwrap();
|
||||
let cursor = table.open(None).unwrap();
|
||||
let rows = read_rows(cursor, 2);
|
||||
assert_eq!(rows, vec![vec![cell!("1"), cell!("A,l,i,c,e")],]);
|
||||
}
|
||||
@@ -598,7 +598,7 @@ mod tests {
|
||||
&format!("filename={}", file.path().to_string_lossy()),
|
||||
"header=false",
|
||||
]);
|
||||
let cursor = table.open().unwrap();
|
||||
let cursor = table.open(None).unwrap();
|
||||
let rows = read_rows(cursor, 3);
|
||||
assert_eq!(
|
||||
rows,
|
||||
@@ -614,7 +614,7 @@ mod tests {
|
||||
"header=false",
|
||||
"schema=CREATE TABLE x(id INT, name TEXT)",
|
||||
]);
|
||||
let cursor = table.open().unwrap();
|
||||
let cursor = table.open(None).unwrap();
|
||||
let rows = read_rows(cursor, 2);
|
||||
assert_eq!(
|
||||
rows,
|
||||
@@ -687,12 +687,7 @@ mod tests {
|
||||
&format!("header={}", val),
|
||||
]);
|
||||
assert!(result.is_ok(), "Expected Ok for header='{}'", val);
|
||||
assert_eq!(
|
||||
result.unwrap().1.header,
|
||||
true,
|
||||
"Expected true for '{}'",
|
||||
val
|
||||
);
|
||||
assert!(!result.unwrap().1.header, "Expected true for '{}'", val);
|
||||
}
|
||||
|
||||
for &val in &false_values {
|
||||
@@ -701,12 +696,7 @@ mod tests {
|
||||
&format!("header={}", val),
|
||||
]);
|
||||
assert!(result.is_ok(), "Expected Ok for header='{}'", val);
|
||||
assert_eq!(
|
||||
result.unwrap().1.header,
|
||||
false,
|
||||
"Expected false for '{}'",
|
||||
val
|
||||
);
|
||||
assert!(!result.unwrap().1.header, "Expected false for '{}'", val);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -729,7 +719,7 @@ mod tests {
|
||||
" data = id,name\n1,Alice\n2,Bob\n ",
|
||||
" header = true ",
|
||||
]);
|
||||
let cursor = table.open().unwrap();
|
||||
let cursor = table.open(None).unwrap();
|
||||
let rows = read_rows(cursor, 2);
|
||||
assert_eq!(
|
||||
rows,
|
||||
@@ -764,7 +754,7 @@ mod tests {
|
||||
"data={}aa{}{}bb{}",
|
||||
quote, quote, quote, quote
|
||||
)]);
|
||||
let cursor = table.open().unwrap();
|
||||
let cursor = table.open(None).unwrap();
|
||||
let rows = read_rows(cursor, 1);
|
||||
assert_eq!(rows, vec![vec![cell!(format!("aa{}bb", quote))]]);
|
||||
}
|
||||
@@ -780,7 +770,7 @@ mod tests {
|
||||
"data={}aa{}{}bb{}",
|
||||
outer, inner, inner, outer
|
||||
)]);
|
||||
let cursor = table.open().unwrap();
|
||||
let cursor = table.open(None).unwrap();
|
||||
let rows = read_rows(cursor, 1);
|
||||
assert_eq!(rows, vec![vec![cell!(format!("aa{}{}bb", inner, inner))]]);
|
||||
}
|
||||
@@ -813,7 +803,7 @@ mod tests {
|
||||
"header=false",
|
||||
"columns=4",
|
||||
]);
|
||||
let cursor = table.open().unwrap();
|
||||
let cursor = table.open(None).unwrap();
|
||||
let rows = read_rows(cursor, 4);
|
||||
assert_eq!(
|
||||
rows,
|
||||
@@ -832,7 +822,7 @@ mod tests {
|
||||
"header=false",
|
||||
"columns=1",
|
||||
]);
|
||||
let cursor = table.open().unwrap();
|
||||
let cursor = table.open(None).unwrap();
|
||||
let rows = read_rows(cursor, 1);
|
||||
assert_eq!(rows, vec![vec![cell!("1")], vec![cell!("2")]]);
|
||||
}
|
||||
@@ -846,7 +836,7 @@ mod tests {
|
||||
"columns=1",
|
||||
"schema='CREATE TABLE x(id INT, name TEXT)'",
|
||||
]);
|
||||
let cursor = table.open().unwrap();
|
||||
let cursor = table.open(None).unwrap();
|
||||
let rows = read_rows(cursor, 2);
|
||||
assert_eq!(rows, vec![vec![cell!("1"), None], vec![cell!("2"), None]]);
|
||||
}
|
||||
@@ -860,7 +850,7 @@ mod tests {
|
||||
"columns=5",
|
||||
"schema='CREATE TABLE x(id INT, name TEXT)'",
|
||||
]);
|
||||
let cursor = table.open().unwrap();
|
||||
let cursor = table.open(None).unwrap();
|
||||
let rows = read_rows(cursor, 2);
|
||||
assert_eq!(
|
||||
rows,
|
||||
@@ -879,7 +869,7 @@ mod tests {
|
||||
"header=true",
|
||||
])
|
||||
.unwrap();
|
||||
let cursor = table.open().unwrap();
|
||||
let cursor = table.open(None).unwrap();
|
||||
let rows = read_rows(cursor, 2);
|
||||
assert_eq!(
|
||||
rows,
|
||||
|
||||
Reference in New Issue
Block a user