• 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

75.81
/src/app/daemonsets.rs
1
use k8s_openapi::{api::apps::v1::DaemonSet, chrono::Utc};
2

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

5
#[derive(Clone, Debug, PartialEq)]
2✔
6
pub struct KubeDaemonSet {
7
  pub name: String,
1✔
8
  pub namespace: String,
1!
9
  pub desired: i32,
1!
10
  pub current: i32,
1!
11
  pub ready: i32,
1!
12
  pub up_to_date: i32,
1!
13
  pub available: i32,
1!
14
  pub age: String,
1!
15
  k8s_obj: DaemonSet,
1!
16
}
17
impl From<DaemonSet> for KubeDaemonSet {
18
  fn from(ds: DaemonSet) -> Self {
1✔
19
    let (desired, current, ready, up_to_date, available) = match ds.status.as_ref() {
2!
20
      Some(s) => (
2✔
21
        s.desired_number_scheduled,
1✔
22
        s.current_number_scheduled,
1✔
23
        s.number_ready,
1✔
24
        s.updated_number_scheduled.unwrap_or_default(),
1✔
25
        s.number_available.unwrap_or_default(),
1✔
26
      ),
1✔
27
      _ => (0, 0, 0, 0, 0),
×
28
    };
29

30
    KubeDaemonSet {
1✔
31
      name: ds.metadata.name.clone().unwrap_or_default(),
1✔
32
      namespace: ds.metadata.namespace.clone().unwrap_or_default(),
1✔
33
      age: utils::to_age(ds.metadata.creation_timestamp.as_ref(), Utc::now()),
1✔
34
      desired,
35
      current,
36
      ready,
37
      up_to_date,
38
      available,
39
      k8s_obj: utils::sanitize_obj(ds),
1✔
40
    }
41
  }
1✔
42
}
43
impl KubeResource<DaemonSet> for KubeDaemonSet {
44
  fn get_k8s_obj(&self) -> &DaemonSet {
×
45
    &self.k8s_obj
×
46
  }
×
47
}
48

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

54
  #[test]
55
  fn test_daemon_sets_from_api() {
2✔
56
    let (dss, dss_list): (Vec<KubeDaemonSet>, Vec<_>) = convert_resource_from_file("daemonsets");
1✔
57

58
    assert_eq!(dss.len(), 1);
1!
59
    assert_eq!(
1✔
60
      dss[0],
1✔
61
      KubeDaemonSet {
1✔
62
        name: "svclb-traefik".into(),
1✔
63
        namespace: "kube-system".into(),
1✔
64
        age: utils::to_age(Some(&get_time("2021-07-05T09:36:45Z")), Utc::now()),
1✔
65
        k8s_obj: dss_list[0].clone(),
1!
66
        desired: 1,
67
        current: 1,
68
        ready: 1,
69
        up_to_date: 1,
70
        available: 1,
71
      }
72
    );
73
  }
2✔
74
}
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