mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-07 18:24:20 +01:00
print diffs in assert tables
This commit is contained in:
@@ -16,6 +16,7 @@ use turso_core::{LimboError, types};
|
||||
use turso_parser::ast::{self, Distinctness};
|
||||
|
||||
use crate::{
|
||||
common::print_diff,
|
||||
generation::{Shadow as _, plan::InteractionType},
|
||||
model::Query,
|
||||
profiles::query::QueryProfile,
|
||||
@@ -1085,20 +1086,21 @@ fn assert_all_table_values(
|
||||
// Check if all values in the table are present in the result set
|
||||
// Find a value in the table that is not in the result set
|
||||
let model_contains_db = table.rows.iter().find(|v| {
|
||||
!vals.iter().any(|r| {
|
||||
&r == v
|
||||
})
|
||||
!vals.contains(v)
|
||||
});
|
||||
let db_contains_model = vals.iter().find(|v| {
|
||||
!table.rows.iter().any(|r| &r == v)
|
||||
!table.rows.contains(v)
|
||||
});
|
||||
|
||||
|
||||
if let Some(model_contains_db) = model_contains_db {
|
||||
tracing::debug!(
|
||||
"table {} does not contain the expected values, the simulator model has more rows than the database: {:?}",
|
||||
table.name,
|
||||
print_row(model_contains_db)
|
||||
);
|
||||
print_diff(&table.rows, vals, "simulator", "database");
|
||||
|
||||
Ok(Err(format!("table {} does not contain the expected values, the simulator model has more rows than the database: {:?}", table.name, print_row(model_contains_db))))
|
||||
} else if let Some(db_contains_model) = db_contains_model {
|
||||
tracing::debug!(
|
||||
@@ -1106,6 +1108,8 @@ fn assert_all_table_values(
|
||||
table.name,
|
||||
print_row(db_contains_model)
|
||||
);
|
||||
print_diff(&table.rows, vals, "simulator", "database");
|
||||
|
||||
Ok(Err(format!("table {} does not contain the expected values, the database has more rows than the simulator model: {:?}", table.name, print_row(db_contains_model))))
|
||||
} else {
|
||||
Ok(Ok(()))
|
||||
|
||||
Reference in New Issue
Block a user