Files
khadhroony-solana-project/crates/ksp-app-backfill-desk/tests/release_completeness.rs
2026-09-02 21:10:07 +02:00

122 lines
4.7 KiB
Rust

// file: crates/ksp-app-backfill-desk/tests/release_completeness.rs
// version: 1
//! Final V1 completeness canaries for the KSP Backfill desktop application.
#![forbid(unsafe_code)]
#![deny(unreachable_pub)]
#![warn(missing_docs)]
fn app_root() -> std::path::PathBuf {
return std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
}
fn read_text(path: &std::path::Path) -> String {
let source = std::fs::read_to_string(path);
assert!(source.is_ok(), "unable to read {}", path.display());
return match source {
std::result::Result::Ok(value) => value,
std::result::Result::Err(_) => String::new(),
};
}
#[test]
fn pre_013_production_module_inventory_is_exact() {
let lib = read_text(app_root().join("src/lib.rs").as_path());
let modules = lib
.lines()
.filter_map(|line| {
let line = line.trim();
if !line.starts_with("mod ") || !line.ends_with(';') {
return std::option::Option::None;
}
return std::option::Option::Some(line.trim_start_matches("mod ").trim_end_matches(';'));
})
.collect::<std::collections::BTreeSet<_>>();
assert_eq!(
modules,
std::collections::BTreeSet::from([
"app_state",
"backfill_request",
"backfill_run",
"backfill_status",
"bootstrap",
"constants",
"dto_backfill",
"dto_common",
"errors",
"frontend_logging",
"logging_runtime",
"splash",
"store_runtime",
"tauri",
"transport_runtime",
"tw_main",
"tw_splash",
])
);
}
#[test]
fn pre_013_integration_suite_inventory_closes_v1_contracts() {
let tests_root = app_root().join("tests");
let entries = std::fs::read_dir(tests_root.as_path());
assert!(entries.is_ok(), "Backfill Desk tests directory should be readable");
let entries = match entries {
std::result::Result::Ok(value) => value,
std::result::Result::Err(_) => return,
};
let files = entries
.flatten()
.filter_map(|entry| {
let path = entry.path();
if path.extension().and_then(std::ffi::OsStr::to_str) != std::option::Option::Some("rs") {
return std::option::Option::None;
}
return path.file_name().and_then(std::ffi::OsStr::to_str).map(str::to_owned);
})
.collect::<std::collections::BTreeSet<_>>();
assert_eq!(
files,
std::collections::BTreeSet::from([
"config_composition.rs".to_owned(),
"dependency_boundary.rs".to_owned(),
"desktop_contract.rs".to_owned(),
"desktop_security.rs".to_owned(),
"public_api.rs".to_owned(),
"release_completeness.rs".to_owned(),
])
);
}
#[test]
fn pre_013_final_surface_contains_every_planned_v1_capability_without_deferred_extensions() {
let tauri = read_text(app_root().join("src/tauri.rs").as_path());
for required in ["backfill_start", "backfill_status", "backfill_cancel", "backfill_resume"] {
assert!(tauri.contains(required), "missing final V1 capability marker {required}");
}
let options = read_text(app_root().join("src/dto_common.rs").as_path());
assert!(options.contains("program_id_options"));
assert!(options.contains("program_id_autocomplete_options"));
let status = read_text(app_root().join("src/backfill_status.rs").as_path());
for required in ["checkpoint_present", "contiguous_completed", "failure_code", "failure_domain"] {
assert!(status.contains(required), "missing final monitoring marker {required}");
}
for forbidden in ["Grpc", "Yellowstone", "WebSocketBackfill", "scheduler", "job_history"] {
assert!(!tauri.contains(forbidden), "deferred capability leaked into V1 Tauri surface via {forbidden}");
}
}
#[test]
fn pre_013_shared_autocomplete_dto_remains_exported_and_consumed_through_crate_root() {
let root = app_root();
let lib = read_text(root.join("src/lib.rs").as_path());
assert!(lib.contains("pub(crate) use self::dto_common::ProgramIdAutocompleteOptionDto;"));
let dto = read_text(root.join("src/dto_common.rs").as_path());
assert!(dto.contains("pub(crate) struct ProgramIdAutocompleteOptionDto"));
assert!(dto.contains("std::vec::Vec<crate::ProgramIdAutocompleteOptionDto>"));
assert!(dto.contains("crate::ProgramIdAutocompleteOptionDto {"));
let bare_construction = dto.matches("\n ProgramIdAutocompleteOptionDto {").count();
assert_eq!(bare_construction, 0, "shared autocomplete DTO must not bypass the crate-root facade");
}