use async_trait::async_trait;
use distributed_cache::{CACHE_ROUTE, HEALTH_ROUTE};
use platform_core::{main_application, overrides, AppError, AutoStart, EntryPoint, Platform};
#[main_application]
struct CacheDisabledTestApp;
#[async_trait]
impl EntryPoint for CacheDisabledTestApp {
async fn start(&self, _args: &[String]) -> Result<(), AppError> {
Ok(())
}
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn nothing_registers_while_the_cache_is_not_enabled() {
platform_core::resources::prepend_resource_root("tests/resources");
overrides::clear("redis.cache.enabled");
AutoStart::main(vec![]).await.expect("lifecycle");
let platform = Platform::get_instance();
assert!(
!platform.has_route(CACHE_ROUTE),
"{CACHE_ROUTE} must stay unregistered without redis.cache.enabled=true"
);
assert!(
!platform.has_route(HEALTH_ROUTE),
"{HEALTH_ROUTE} is gated by the same switch"
);
}