blob: de256d80bbcc3885a365ca7dc4f0779ca20f2c83 (
plain)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
use std::default::Default;
#[derive(Default, Debug)]
pub struct CloudInitConfig {
hostname: String,
authorized_keys: String,
}
impl CloudInitConfig {
pub fn hostname(&self) -> &str {
&self.hostname
}
pub fn set_hostname(&mut self, hostname: &str) {
self.hostname = hostname.to_string();
}
pub fn authorized_keys(&self) -> &str {
&self.authorized_keys
}
pub fn set_authorized_keys(&mut self, keys: &str) {
self.authorized_keys = keys.to_string();
}
}
#[cfg(test)]
mod test {
use super::CloudInitConfig;
#[test]
fn is_empty_by_default() {
let init = CloudInitConfig::default();
assert_eq!(init.hostname(), "");
assert_eq!(init.authorized_keys(), "");
}
#[test]
fn sets_hostname() {
let mut init = CloudInitConfig::default();
init.set_hostname("foo");
assert_eq!(init.hostname(), "foo");
}
#[test]
fn sets_authorized_keys() {
let mut init = CloudInitConfig::default();
init.set_authorized_keys("auth");
assert_eq!(init.authorized_keys(), "auth");
}
}
|