forked from torrust/torrust-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtracker_client.rs
More file actions
62 lines (50 loc) · 1.83 KB
/
Copy pathtracker_client.rs
File metadata and controls
62 lines (50 loc) · 1.83 KB
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
52
53
54
55
56
57
58
59
60
61
62
//! Integration tests for the unified `tracker_client` binary.
mod common;
use std::process::Command;
fn tracker_client_bin() -> Command {
Command::new(common::resolve_tracker_client_binary())
}
#[test]
fn it_should_show_unified_subcommands_in_help() {
let output = tracker_client_bin()
.arg("--help")
.output()
.expect("Failed to run tracker_client --help");
assert_eq!(output.status.code(), Some(0));
let stdout = String::from_utf8_lossy(&output.stdout);
assert!(stdout.contains("http"), "Expected http subcommand in help output: {stdout}");
assert!(stdout.contains("udp"), "Expected udp subcommand in help output: {stdout}");
assert!(stdout.contains("check"), "Expected check subcommand in help output: {stdout}");
}
#[test]
fn it_should_fail_http_announce_for_invalid_infohash() {
let output = tracker_client_bin()
.arg("http")
.arg("announce")
.arg("http://127.0.0.1:7070")
.arg("invalid_info_hash")
.output()
.expect("Failed to run tracker_client http announce");
assert_eq!(output.status.code(), Some(1));
let stderr = String::from_utf8_lossy(&output.stderr);
assert!(
stderr.contains("invalid infohash"),
"Expected invalid infohash message, got: {stderr}"
);
}
#[test]
fn it_should_fail_udp_scrape_for_invalid_infohash() {
let output = tracker_client_bin()
.arg("udp")
.arg("scrape")
.arg("udp://127.0.0.1:6969")
.arg("invalid_info_hash")
.output()
.expect("Failed to run tracker_client udp scrape");
assert_eq!(output.status.code(), Some(2));
let stderr = String::from_utf8_lossy(&output.stderr);
assert!(
stderr.contains("failed to parse info-hash"),
"Expected clap validation error with info-hash parse failure, got: {stderr}"
);
}