generator checkpoint
This commit is contained in:
@ -259,3 +259,25 @@ pub fn update_sql_fixture(path: &str, suite_idx: usize, case_idx: usize, queries
|
||||
let formatted_json = serde_json::to_string_pretty(&file_data).unwrap();
|
||||
fs::write(path, formatted_json).unwrap();
|
||||
}
|
||||
|
||||
pub fn update_schemas_fixture(path: &str, suite_idx: usize, case_idx: usize, db: &crate::database::Database) {
|
||||
let content = fs::read_to_string(path).unwrap();
|
||||
let mut file_data: Value = serde_json::from_str(&content).unwrap();
|
||||
|
||||
if let Some(expect) = file_data[suite_idx]["tests"][case_idx].get_mut("expect") {
|
||||
if let Some(schemas_map) = expect.get_mut("schemas").and_then(|v| v.as_object_mut()) {
|
||||
for (key, expected_val) in schemas_map {
|
||||
if expected_val.is_object() && expected_val.as_object().unwrap().is_empty() {
|
||||
continue;
|
||||
}
|
||||
if let Some(actual_ast) = db.schemas.get(key) {
|
||||
let actual_val = serde_json::to_value(actual_ast).unwrap();
|
||||
*expected_val = actual_val;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let formatted_json = serde_json::to_string_pretty(&file_data).unwrap();
|
||||
fs::write(path, formatted_json).unwrap();
|
||||
}
|
||||
|
||||
@ -57,6 +57,9 @@ impl Case {
|
||||
|
||||
if env::var("UPDATE_EXPECT").is_ok() {
|
||||
update_validation_fixture(path, suite_idx, case_idx, &result.errors);
|
||||
if let Ok(db) = db_res {
|
||||
crate::tests::runner::update_schemas_fixture(path, suite_idx, case_idx, db);
|
||||
}
|
||||
}
|
||||
|
||||
expect.assert_drop(&result)?;
|
||||
|
||||
Reference in New Issue
Block a user