aboutsummaryrefslogtreecommitdiffstats
path: root/crates/api-base/src/health/mod.rs
blob: a84dc855b5aca5209e98e7e217a33fa5da331de6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#[cfg(feature = "utoipa")]
mod apidoc;

#[cfg(feature = "utoipa")]
pub use apidoc::*;

#[derive(Default)]
pub struct BaseService;

impl HealthDriver for BaseService {}

pub trait HealthDriver: Send + Sync {
    fn health(&self, app: &str, version: &str) -> String {
        format!("{app} v{version} is live")
    }
}

#[cfg(test)]
mod tests {
    use crate::health::{BaseService, HealthDriver};

    #[test]
    fn health() {
        let app = BaseService.health(env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION"));
        assert!(app.contains("is live"));
    }
}