Test for upgrade

This commit is contained in:
Mubelotix
2025-08-26 14:33:43 +02:00
parent 0558d41930
commit 36ff335a4d

View File

@ -1,6 +1,9 @@
use std::{sync::Arc, time::Duration}; use std::{sync::Arc, time::Duration};
use crate::common::{args::CommonArgs, client::Client, logs::setup_logs, workload::Workload}; use crate::{
common::{args::CommonArgs, client::Client, logs::setup_logs, workload::Workload},
test::workload::CommandOrUpgrade,
};
use anyhow::{bail, Context}; use anyhow::{bail, Context};
use clap::Parser; use clap::Parser;
@ -62,12 +65,20 @@ async fn run_inner(args: TestDeriveArgs) -> anyhow::Result<()> {
bail!("workload file {} is not a test workload", workload_file.display()); bail!("workload file {} is not a test workload", workload_file.display());
}; };
let has_upgrade =
workload.commands.iter().any(|c| matches!(c, CommandOrUpgrade::Upgrade { .. }));
let name = workload.name.clone(); let name = workload.name.clone();
match workload.run(&args, &assets_client, &meili_client, asset_folder).await { match workload.run(&args, &assets_client, &meili_client, asset_folder).await {
Ok(_) => match args.add_missing_responses || args.update_responses { Ok(_) => {
match args.add_missing_responses || args.update_responses {
true => println!("🛠️ Workload {name} was updated"), true => println!("🛠️ Workload {name} was updated"),
false => println!("✅ Workload {name} passed"), false => println!("✅ Workload {name} passed"),
} }
if !has_upgrade {
println!("⚠️ Warning: this workload doesn't contain an upgrade. The whole point of these tests is to test upgrades! Please add one.");
}
}
Err(error) => { Err(error) => {
println!("❌ Workload {name} failed: {error}"); println!("❌ Workload {name} failed: {error}");
println!("💡 Is this intentional? If so, rerun with --update-responses to update the workload files."); println!("💡 Is this intentional? If so, rerun with --update-responses to update the workload files.");