nomad_client_rs/api/
mod.rs

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
28
29
30
pub mod acl;
pub mod allocation;
pub mod client;
pub mod deployment;
pub mod event;
pub mod job;
pub mod namespace;
pub mod service;
pub mod status;
pub mod variable;

pub fn path_combine(a: &str, b: &str) -> String {
    let a = a.trim_end_matches('/');
    let b = b.trim_start_matches('/');
    format!("{}/{}", a, b)
}

#[cfg(test)]
mod tests {
    use crate::api::path_combine;

    #[test]
    fn path_combine_should_return_valid_path() {
        assert_eq!("/a/b", path_combine("/a", "/b"));
        assert_eq!("/a/b", path_combine("/a/", "/b"));
        assert_eq!("/a/b", path_combine("/a", "b"));
        assert_eq!("a/b", path_combine("a", "b"));
        assert_eq!("a/b", path_combine("a", "/b"));
    }
}