1
//! Tenants that exist but were never migrated reach the current schema.
2
#![cfg(feature = "db")]
3

            
4
use server::fleet::migrate_fleet;
5
use tests_integration::fleet_support::{
6
    accounted_for, admin_connect, admin_id, is_fully_migrated, quarantine_of, register_tenant,
7
};
8

            
9
#[tokio::test]
10
1
async fn every_reachable_tenant_reaches_the_current_schema() -> anyhow::Result<()> {
11
1
    let admin = admin_connect().await;
12
1
    let (first, first_db, _first_guard) = register_tenant(&admin, "fleet-a", true).await;
13
1
    let (second, second_db, _second_guard) = register_tenant(&admin, "fleet-b", true).await;
14

            
15
1
    assert!(
16
1
        !is_fully_migrated(&first_db).await,
17
        "precondition: a bare CREATE DATABASE has no schema"
18
    );
19

            
20
1
    let report = migrate_fleet(admin_id()).await?;
21

            
22
1
    assert!(accounted_for(&report, first), "{report:?}");
23
1
    assert!(accounted_for(&report, second), "{report:?}");
24
1
    assert!(
25
1
        is_fully_migrated(&first_db).await,
26
        "a visited tenant must carry the whole migration set, not merely some of it"
27
    );
28
1
    assert!(is_fully_migrated(&second_db).await);
29
1
    assert_eq!(quarantine_of(&admin, first).await, None);
30
1
    assert_eq!(quarantine_of(&admin, second).await, None);
31
2
    Ok(())
32
1
}