Skip to content

Commit 16a760b

Browse files
committed
updating coverage
1 parent 0bdd7d4 commit 16a760b

3 files changed

Lines changed: 88 additions & 0 deletions

File tree

src/args/cli.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,25 @@ mod tests {
9191
assert!(validate(&result));
9292
}
9393

94+
#[test]
95+
fn validate_returns_false_for_empty_item() {
96+
assert!(!validate(&CliArgs {
97+
item: " ".to_string(),
98+
config: "kickable.yaml".to_string(),
99+
}));
100+
}
101+
102+
#[test]
103+
fn display_produces_string() {
104+
// Display prints the current process args; just verify it doesn't panic
105+
// and produces a non-empty string (the test binary path is always present).
106+
let args = CliArgs {
107+
item: "it".to_string(),
108+
config: "kickable.yaml".to_string(),
109+
};
110+
assert!(!format!("{args}").is_empty());
111+
}
112+
94113
#[test]
95114
fn test_to_config() {
96115
let _result = CliArgs {

src/args/client.rs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,46 @@ mod tests {
9393
}
9494
.to_config();
9595
}
96+
97+
fn write_temp_yaml(name: &str, content: &str) -> String {
98+
let path = std::env::temp_dir().join(name);
99+
std::fs::write(&path, content).unwrap();
100+
path.to_string_lossy().into_owned()
101+
}
102+
103+
#[test]
104+
fn validate_returns_false_when_no_client_section() {
105+
let path = write_temp_yaml("kickable_test_client_none.yaml", "items:\n - it\n");
106+
assert!(!validate(&ClientArgs {
107+
item: "it".to_string(),
108+
config: path,
109+
}));
110+
}
111+
112+
#[test]
113+
fn validate_returns_false_for_empty_item() {
114+
assert!(!validate(&ClientArgs {
115+
item: " ".to_string(),
116+
config: "kickable.yaml".to_string(),
117+
}));
118+
}
119+
120+
#[test]
121+
fn display_returns_empty_when_no_client_section() {
122+
let path = write_temp_yaml("kickable_test_client_display_none.yaml", "items:\n - it\n");
123+
let args = ClientArgs {
124+
item: "it".to_string(),
125+
config: path,
126+
};
127+
assert_eq!(format!("{args}"), "");
128+
}
129+
130+
#[test]
131+
fn display_returns_addr_port() {
132+
let args = ClientArgs {
133+
item: "it".to_string(),
134+
config: "kickable.yaml".to_string(),
135+
};
136+
assert_eq!(format!("{args}"), "0.0.0.0:8080");
137+
}
96138
}

src/args/service.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,31 @@ mod tests {
9090
}
9191
.to_config();
9292
}
93+
94+
fn write_temp_yaml(name: &str, content: &str) -> String {
95+
let path = std::env::temp_dir().join(name);
96+
std::fs::write(&path, content).unwrap();
97+
path.to_string_lossy().into_owned()
98+
}
99+
100+
#[test]
101+
fn validate_returns_false_when_no_server_section() {
102+
let path = write_temp_yaml("kickable_test_service_none.yaml", "items:\n - it\n");
103+
assert!(!validate(&ServiceArgs { config: path }));
104+
}
105+
106+
#[test]
107+
fn display_returns_empty_when_no_server_section() {
108+
let path = write_temp_yaml("kickable_test_service_display_none.yaml", "items:\n - it\n");
109+
let args = ServiceArgs { config: path };
110+
assert_eq!(format!("{args}"), "");
111+
}
112+
113+
#[test]
114+
fn display_returns_addr_port() {
115+
let args = ServiceArgs {
116+
config: "kickable.yaml".to_string(),
117+
};
118+
assert_eq!(format!("{args}"), "0.0.0.0:8080");
119+
}
93120
}

0 commit comments

Comments
 (0)