• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

kdash-rs / kdash / 3750513782

pending completion
3750513782

push

github

Deepu
fix tests

982 of 4441 branches covered (22.11%)

Branch coverage included in aggregate %.

2731 of 4724 relevant lines covered (57.81%)

8.14 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

79.31
/src/app/deployments.rs
1
use k8s_openapi::{api::apps::v1::Deployment, chrono::Utc};
2

3
use super::{models::KubeResource, utils};
4

5
#[derive(Clone, Debug, PartialEq)]
2✔
6
pub struct KubeDeployment {
7
  pub name: String,
1✔
8
  pub namespace: String,
1!
9
  pub ready: String,
1!
10
  pub updated: i32,
1!
11
  pub available: i32,
1!
12
  pub age: String,
1!
13
  k8s_obj: Deployment,
1!
14
}
15

16
impl From<Deployment> for KubeDeployment {
17
  fn from(deployment: Deployment) -> Self {
4✔
18
    let (ready, available, updated) = match &deployment.status {
8!
19
      Some(s) => (
8✔
20
        format!(
8✔
21
          "{}/{}",
22
          s.available_replicas.unwrap_or_default(),
4✔
23
          s.replicas.unwrap_or_default()
4✔
24
        ),
25
        s.available_replicas.unwrap_or_default(),
4✔
26
        s.updated_replicas.unwrap_or_default(),
4✔
27
      ),
4✔
28
      _ => ("".into(), 0, 0),
×
29
    };
30

31
    Self {
4✔
32
      name: deployment.metadata.name.clone().unwrap_or_default(),
4✔
33
      namespace: deployment.metadata.namespace.clone().unwrap_or_default(),
4✔
34
      age: utils::to_age(deployment.metadata.creation_timestamp.as_ref(), Utc::now()),
4✔
35
      available,
36
      updated,
37
      ready,
4✔
38
      k8s_obj: utils::sanitize_obj(deployment),
4✔
39
    }
40
  }
4✔
41
}
42
impl KubeResource<Deployment> for KubeDeployment {
43
  fn get_k8s_obj(&self) -> &Deployment {
×
44
    &self.k8s_obj
45
  }
×
46
}
47

48
#[cfg(test)]
49
mod tests {
50
  use super::*;
51
  use crate::app::test_utils::*;
52

53
  #[test]
54
  fn test_deployments_from_api() {
2✔
55
    let (deployments, deployment_list): (Vec<KubeDeployment>, Vec<_>) =
1✔
56
      convert_resource_from_file("deployments");
1✔
57

58
    assert_eq!(deployments.len(), 4);
1!
59
    assert_eq!(
1✔
60
      deployments[0],
1✔
61
      KubeDeployment {
1✔
62
        name: "metrics-server".into(),
1✔
63
        namespace: "kube-system".into(),
1✔
64
        age: utils::to_age(Some(&get_time("2021-05-10T21:48:06Z")), Utc::now()),
1✔
65
        k8s_obj: deployment_list[0].clone(),
1✔
66
        available: 1,
67
        updated: 1,
68
        ready: "1/1".into(),
1!
69
      }
70
    );
71
  }
2✔
72
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc