Lines
100 %
Functions
Branches
//! Tenants that exist but were never migrated reach the current schema.
#![cfg(feature = "db")]
use server::fleet::migrate_fleet;
use tests_integration::fleet_support::{
accounted_for, admin_connect, admin_id, forget_tenant, is_fully_migrated, quarantine_of,
register_tenant,
};
#[tokio::test]
async fn every_reachable_tenant_reaches_the_current_schema() -> anyhow::Result<()> {
let admin = admin_connect().await;
let (first, first_db) = register_tenant(&admin, "fleet-a", true).await;
let (second, second_db) = register_tenant(&admin, "fleet-b", true).await;
assert!(
!is_fully_migrated(&first_db).await,
"precondition: a bare CREATE DATABASE has no schema"
);
let report = migrate_fleet(admin_id()).await?;
assert!(accounted_for(&report, first), "{report:?}");
assert!(accounted_for(&report, second), "{report:?}");
is_fully_migrated(&first_db).await,
"a visited tenant must carry the whole migration set, not merely some of it"
assert!(is_fully_migrated(&second_db).await);
assert_eq!(quarantine_of(&admin, first).await, None);
assert_eq!(quarantine_of(&admin, second).await, None);
forget_tenant(&admin, first, &first_db).await;
forget_tenant(&admin, second, &second_db).await;
Ok(())
}