• 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

72.5
/src/app/ns.rs
1
use k8s_openapi::api::core::v1::Namespace;
2

3
use super::{
4
  models::KubeResource,
5
  utils::{self, UNKNOWN},
6
};
7

8
#[derive(Clone, Debug, PartialEq, Default)]
20✔
9
pub struct KubeNs {
10
  pub name: String,
10✔
11
  pub status: String,
10!
12
  k8s_obj: Namespace,
10!
13
}
14

15
impl From<Namespace> for KubeNs {
16
  fn from(ns: Namespace) -> Self {
4✔
17
    let status = match &ns.status {
4!
18
      Some(stat) => match &stat.phase {
4!
19
        Some(phase) => phase.clone(),
4✔
20
        _ => UNKNOWN.into(),
×
21
      },
22
      _ => UNKNOWN.into(),
×
23
    };
24

25
    KubeNs {
4✔
26
      name: ns.metadata.name.clone().unwrap_or_default(),
4✔
27
      status,
4✔
28
      k8s_obj: utils::sanitize_obj(ns),
4✔
29
    }
30
  }
4✔
31
}
32

33
impl KubeResource<Namespace> for KubeNs {
34
  fn get_k8s_obj(&self) -> &Namespace {
×
35
    &self.k8s_obj
×
36
  }
×
37
}
38

39
#[cfg(test)]
40
mod tests {
41
  use super::*;
42
  use crate::app::test_utils::convert_resource_from_file;
43

44
  #[test]
45
  fn test_namespace_from_api() {
2✔
46
    let (nss, ns_list): (Vec<KubeNs>, Vec<_>) = convert_resource_from_file("ns");
1✔
47

48
    assert_eq!(nss.len(), 4);
1!
49
    assert_eq!(
1✔
50
      nss[0],
1✔
51
      KubeNs {
1✔
52
        name: "default".into(),
1✔
53
        status: "Active".into(),
1✔
54
        k8s_obj: ns_list[0].clone()
1!
55
      }
56
    );
57
  }
2✔
58
}
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