• 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

76.92
/src/app/replicasets.rs
1
use k8s_openapi::{api::apps::v1::ReplicaSet, chrono::Utc};
2

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

5
#[derive(Clone, Debug, PartialEq)]
2✔
6
pub struct KubeReplicaSet {
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 age: String,
1!
13
  k8s_obj: ReplicaSet,
1!
14
}
15

16
impl From<ReplicaSet> for KubeReplicaSet {
17
  fn from(rps: ReplicaSet) -> Self {
4✔
18
    let (current, ready) = match rps.status.as_ref() {
8!
19
      Some(s) => (s.replicas, s.ready_replicas.unwrap_or_default()),
4✔
20
      _ => (0, 0),
×
21
    };
22

23
    KubeReplicaSet {
4✔
24
      name: rps.metadata.name.clone().unwrap_or_default(),
4✔
25
      namespace: rps.metadata.namespace.clone().unwrap_or_default(),
4✔
26
      age: utils::to_age(rps.metadata.creation_timestamp.as_ref(), Utc::now()),
4✔
27
      desired: rps
4✔
28
        .spec
29
        .as_ref()
30
        .map_or(0, |s| s.replicas.unwrap_or_default()),
4✔
31
      current,
32
      ready,
33
      k8s_obj: utils::sanitize_obj(rps),
4✔
34
    }
35
  }
4✔
36
}
37

38
impl KubeResource<ReplicaSet> for KubeReplicaSet {
39
  fn get_k8s_obj(&self) -> &ReplicaSet {
×
40
    &self.k8s_obj
41
  }
×
42
}
43

44
#[cfg(test)]
45
mod tests {
46
  use super::*;
47
  use crate::app::test_utils::*;
48

49
  #[test]
50
  fn test_replica_sets_from_api() {
2✔
51
    let (rpls, rpls_list): (Vec<KubeReplicaSet>, Vec<_>) =
1✔
52
      convert_resource_from_file("replicasets");
1✔
53

54
    assert_eq!(rpls.len(), 4);
1!
55
    assert_eq!(
1✔
56
      rpls[0],
1✔
57
      KubeReplicaSet {
1✔
58
        name: "metrics-server-86cbb8457f".into(),
1✔
59
        namespace: "kube-system".into(),
1✔
60
        age: utils::to_age(Some(&get_time("2021-05-10T21:48:19Z")), Utc::now()),
1✔
61
        k8s_obj: rpls_list[0].clone(),
1!
62
        desired: 1,
63
        current: 1,
64
        ready: 1,
65
      }
66
    );
67
  }
2✔
68
}
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