Update integration tests to use the new retrieval methods to access Record values.

This commit is contained in:
Tiago Ribeiro
2025-02-10 00:22:25 -07:00
parent c071e47b03
commit d00b44d7cd
5 changed files with 23 additions and 23 deletions

View File

@@ -30,7 +30,7 @@ fn test_last_insert_rowid_basic() -> anyhow::Result<()> {
match rows.step()? {
StepResult::Row => {
let row = rows.row().unwrap();
if let Value::Integer(id) = row.values[0].to_value() {
if let Value::Integer(id) = row.get_value(0).to_value() {
assert_eq!(id, 1, "First insert should have rowid 1");
}
}
@@ -66,7 +66,7 @@ fn test_last_insert_rowid_basic() -> anyhow::Result<()> {
match rows.step()? {
StepResult::Row => {
let row = rows.row().unwrap();
if let Value::Integer(id) = row.values[0].to_value() {
if let Value::Integer(id) = row.get_value(0).to_value() {
last_id = id;
}
}
@@ -112,7 +112,7 @@ fn test_integer_primary_key() -> anyhow::Result<()> {
match select_query.step()? {
StepResult::Row => {
let row = select_query.row().unwrap();
if let Value::Integer(id) = row.values[0].to_value() {
if let Value::Integer(id) = row.get_value(0).to_value() {
rowids.push(id);
}
}

View File

@@ -56,7 +56,7 @@ mod tests {
r => panic!("unexpected result {:?}: expecting single row", r),
}
};
row.values
row.get_values()
.iter()
.map(|x| match x.to_value() {
limbo_core::Value::Null => rusqlite::types::Value::Null,

View File

@@ -15,7 +15,7 @@ fn test_statement_reset_bind() -> anyhow::Result<()> {
match stmt.step()? {
StepResult::Row => {
let row = stmt.row().unwrap();
assert_eq!(row.values[0].to_value(), Value::Integer(1));
assert_eq!(row.get_value(0).to_value(), Value::Integer(1));
}
StepResult::IO => tmp_db.io.run_once()?,
_ => break,
@@ -30,7 +30,7 @@ fn test_statement_reset_bind() -> anyhow::Result<()> {
match stmt.step()? {
StepResult::Row => {
let row = stmt.row().unwrap();
assert_eq!(row.values[0].to_value(), Value::Integer(2));
assert_eq!(row.get_value(0).to_value(), Value::Integer(2));
}
StepResult::IO => tmp_db.io.run_once()?,
_ => break,
@@ -63,23 +63,23 @@ fn test_statement_bind() -> anyhow::Result<()> {
match stmt.step()? {
StepResult::Row => {
let row = stmt.row().unwrap();
if let Value::Text(s) = row.values[0].to_value() {
if let Value::Text(s) = row.get_value(0).to_value() {
assert_eq!(s, "hello")
}
if let Value::Text(s) = row.values[1].to_value() {
if let Value::Text(s) = row.get_value(1).to_value() {
assert_eq!(s, "hello")
}
if let Value::Integer(i) = row.values[2].to_value() {
if let Value::Integer(i) = row.get_value(2).to_value() {
assert_eq!(i, 42)
}
if let Value::Blob(v) = row.values[3].to_value() {
if let Value::Blob(v) = row.get_value(3).to_value() {
assert_eq!(v, &vec![0x1 as u8, 0x2, 0x3])
}
if let Value::Float(f) = row.values[4].to_value() {
if let Value::Float(f) = row.get_value(4).to_value() {
assert_eq!(f, 0.5)
}
}

View File

@@ -43,8 +43,8 @@ fn test_simple_overflow_page() -> anyhow::Result<()> {
match rows.step()? {
StepResult::Row => {
let row = rows.row().unwrap();
let first_value = row.values[0].to_value();
let text = row.values[1].to_value();
let first_value = row.get_value(0).to_value();
let text = row.get_value(1).to_value();
let id = match first_value {
Value::Integer(i) => i as i32,
Value::Float(f) => f as i32,
@@ -118,8 +118,8 @@ fn test_sequential_overflow_page() -> anyhow::Result<()> {
match rows.step()? {
StepResult::Row => {
let row = rows.row().unwrap();
let first_value = row.values[0].to_value();
let text = row.values[1].to_value();
let first_value = row.get_value(0).to_value();
let text = row.get_value(1).to_value();
let id = match first_value {
Value::Integer(i) => i as i32,
Value::Float(f) => f as i32,
@@ -190,7 +190,7 @@ fn test_sequential_write() -> anyhow::Result<()> {
match rows.step()? {
StepResult::Row => {
let row = rows.row().unwrap();
let first_value = row.values.first().expect("missing id");
let first_value = row.get_values().first().expect("missing id");
let id = match first_value.to_value() {
Value::Integer(i) => i as i32,
Value::Float(f) => f as i32,
@@ -256,7 +256,7 @@ fn test_regression_multi_row_insert() -> anyhow::Result<()> {
match rows.step()? {
StepResult::Row => {
let row = rows.row().unwrap();
let first_value = row.values.first().expect("missing id");
let first_value = row.get_values().first().expect("missing id");
let id = match first_value.to_value() {
Value::Float(f) => f as i32,
_ => panic!("expected float"),
@@ -302,7 +302,7 @@ fn test_statement_reset() -> anyhow::Result<()> {
match stmt.step()? {
StepResult::Row => {
let row = stmt.row().unwrap();
assert_eq!(row.values[0].to_value(), Value::Integer(1));
assert_eq!(row.get_value(0).to_value(), Value::Integer(1));
break;
}
StepResult::IO => tmp_db.io.run_once()?,
@@ -316,7 +316,7 @@ fn test_statement_reset() -> anyhow::Result<()> {
match stmt.step()? {
StepResult::Row => {
let row = stmt.row().unwrap();
assert_eq!(row.values[0].to_value(), Value::Integer(1));
assert_eq!(row.get_value(0).to_value(), Value::Integer(1));
break;
}
StepResult::IO => tmp_db.io.run_once()?,
@@ -366,7 +366,7 @@ fn test_wal_checkpoint() -> anyhow::Result<()> {
match rows.step()? {
StepResult::Row => {
let row = rows.row().unwrap();
let first_value = row.values[0].to_value();
let first_value = row.get_value(0).to_value();
let id = match first_value {
Value::Integer(i) => i as i32,
Value::Float(f) => f as i32,
@@ -430,7 +430,7 @@ fn test_wal_restart() -> anyhow::Result<()> {
match rows.step()? {
StepResult::Row => {
let row = rows.row().unwrap();
let first_value = row.values[0].to_value();
let first_value = row.get_value(0).to_value();
let count = match first_value {
Value::Integer(i) => i,
_ => unreachable!(),

View File

@@ -44,7 +44,7 @@ pub(crate) fn execute_and_get_strings(
match step_result {
StepResult::Row => {
let row = stmt.row().unwrap();
for el in &row.values {
for el in row.get_values() {
result.push(format!("{el}"));
}
}
@@ -72,7 +72,7 @@ pub(crate) fn execute_and_get_ints(
match step_result {
StepResult::Row => {
let row = stmt.row().unwrap();
for value in &row.values {
for value in row.get_values() {
let value = value.to_value();
let out = match value {
Value::Integer(i) => i,