Compare commits
2
Commits
9992a2bff0
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
21749a62ea
|
||
|
|
947b3c2eda
|
No files matched your search
+2
-2
@@ -51,8 +51,8 @@ pub enum Command {
|
|||||||
},
|
},
|
||||||
|
|
||||||
#[command(about = indoc!{"
|
#[command(about = indoc!{"
|
||||||
Print the full path to the default configuration file.
|
Print the full path to the configuration file in use.
|
||||||
This file can be changed to another location using the '--config-file' flag
|
This is the default configuration file location unless overridden with the '--config-file' flag
|
||||||
"})]
|
"})]
|
||||||
ConfigPath,
|
ConfigPath,
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-2
@@ -131,7 +131,10 @@ async fn main() -> Result<()> {
|
|||||||
let default_config_path = config_file_path.display().to_string();
|
let default_config_path = config_file_path.display().to_string();
|
||||||
|
|
||||||
if matches!(args.command, Some(Command::ConfigPath)) {
|
if matches!(args.command, Some(Command::ConfigPath)) {
|
||||||
println!("{default_config_path}");
|
match args.global.config_file {
|
||||||
|
Some(ref config_file) => println!("{}", config_file.display()),
|
||||||
|
None => println!("{default_config_path}"),
|
||||||
|
}
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,7 +156,6 @@ async fn main() -> Result<()> {
|
|||||||
config.validate(&config_path);
|
config.validate(&config_path);
|
||||||
config.post_process_initialization();
|
config.post_process_initialization();
|
||||||
|
|
||||||
let reqwest_client = build_network_client(&config);
|
|
||||||
let (sync_network_tx, sync_network_rx) = mpsc::channel(500);
|
let (sync_network_tx, sync_network_rx) = mpsc::channel(500);
|
||||||
let cancellation_token = CancellationToken::new();
|
let cancellation_token = CancellationToken::new();
|
||||||
let ctrlc_cancellation_token = cancellation_token.clone();
|
let ctrlc_cancellation_token = cancellation_token.clone();
|
||||||
@@ -185,6 +187,7 @@ async fn main() -> Result<()> {
|
|||||||
match args.command {
|
match args.command {
|
||||||
Some(command) => match command {
|
Some(command) => match command {
|
||||||
Command::Radarr(_) | Command::Sonarr(_) | Command::Lidarr(_) | Command::Readarr(_) => {
|
Command::Radarr(_) | Command::Sonarr(_) | Command::Lidarr(_) | Command::Readarr(_) => {
|
||||||
|
let reqwest_client = build_network_client(&config);
|
||||||
if spinner_disabled {
|
if spinner_disabled {
|
||||||
start_cli_no_spinner(
|
start_cli_no_spinner(
|
||||||
config,
|
config,
|
||||||
@@ -219,6 +222,7 @@ async fn main() -> Result<()> {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
None => {
|
None => {
|
||||||
|
let reqwest_client = build_network_client(&config);
|
||||||
let app_nw = Arc::clone(&app);
|
let app_nw = Arc::clone(&app);
|
||||||
std::thread::spawn(move || {
|
std::thread::spawn(move || {
|
||||||
start_networking(sync_network_rx, &app_nw, cancellation_token, reqwest_client)
|
start_networking(sync_network_rx, &app_nw, cancellation_token, reqwest_client)
|
||||||
|
|||||||
@@ -43,6 +43,8 @@ impl ProbeEnv {
|
|||||||
.env("HOME", self.base.join("home"))
|
.env("HOME", self.base.join("home"))
|
||||||
.env("XDG_CACHE_HOME", self.blocked_cache_dir())
|
.env("XDG_CACHE_HOME", self.blocked_cache_dir())
|
||||||
.env("TMPDIR", self.base.join("fresh_tmp"))
|
.env("TMPDIR", self.base.join("fresh_tmp"))
|
||||||
|
.env("SSL_CERT_FILE", self.base.join("no_certs.crt"))
|
||||||
|
.env("SSL_CERT_DIR", self.base.join("no_certs_dir"))
|
||||||
.arg("--config-file")
|
.arg("--config-file")
|
||||||
.arg(self.base.join("config.yml"));
|
.arg(self.base.join("config.yml"));
|
||||||
command
|
command
|
||||||
@@ -164,6 +166,8 @@ fn unset_home_does_not_panic_on_startup() {
|
|||||||
.env_clear()
|
.env_clear()
|
||||||
.env("PATH", std::env::var_os("PATH").unwrap())
|
.env("PATH", std::env::var_os("PATH").unwrap())
|
||||||
.env("TMPDIR", env.base.join("fresh_tmp"))
|
.env("TMPDIR", env.base.join("fresh_tmp"))
|
||||||
|
.env("SSL_CERT_FILE", env.base.join("no_certs.crt"))
|
||||||
|
.env("SSL_CERT_DIR", env.base.join("no_certs_dir"))
|
||||||
.current_dir(&env.base)
|
.current_dir(&env.base)
|
||||||
.arg("--config-file")
|
.arg("--config-file")
|
||||||
.arg(env.base.join("config.yml"))
|
.arg(env.base.join("config.yml"))
|
||||||
@@ -182,3 +186,51 @@ fn unset_home_does_not_panic_on_startup() {
|
|||||||
"binary panicked instead of degrading gracefully: {stderr}"
|
"binary panicked instead of degrading gracefully: {stderr}"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
#[test]
|
||||||
|
fn config_path_succeeds_without_loadable_tls_certificates() {
|
||||||
|
let env = ProbeEnv::new("config_path");
|
||||||
|
|
||||||
|
let mut command = env.command();
|
||||||
|
let assertion = command.arg("config-path").assert().success();
|
||||||
|
let output = assertion.get_output();
|
||||||
|
let stderr = str::from_utf8(&output.stderr).unwrap();
|
||||||
|
|
||||||
|
let stdout = str::from_utf8(&output.stdout).unwrap();
|
||||||
|
assert_eq!(
|
||||||
|
stdout.trim_end(),
|
||||||
|
env.base.join("config.yml").display().to_string(),
|
||||||
|
"config-path did not print the config file passed via --config-file"
|
||||||
|
);
|
||||||
|
assert!(
|
||||||
|
!stderr.contains("builder error"),
|
||||||
|
"config-path built the reqwest client despite needing no network: {stderr}"
|
||||||
|
);
|
||||||
|
assert!(
|
||||||
|
!stderr.contains("panicked"),
|
||||||
|
"binary panicked instead of degrading gracefully: {stderr}"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
#[test]
|
||||||
|
fn servarr_command_without_loadable_tls_certificates_reports_builder_error() {
|
||||||
|
let env = ProbeEnv::new("servarr_builder_error");
|
||||||
|
|
||||||
|
let mut command = env.command();
|
||||||
|
let assertion = command
|
||||||
|
.args(["--disable-spinner", "radarr", "list", "movies"])
|
||||||
|
.assert()
|
||||||
|
.failure();
|
||||||
|
let stderr = str::from_utf8(&assertion.get_output().stderr).unwrap();
|
||||||
|
|
||||||
|
assert!(
|
||||||
|
stderr.contains("error: builder error"),
|
||||||
|
"network-bound command did not surface the client builder failure: {stderr}"
|
||||||
|
);
|
||||||
|
assert!(
|
||||||
|
!stderr.contains("panicked"),
|
||||||
|
"builder failure panicked instead of exiting cleanly: {stderr}"
|
||||||
|
);
|
||||||
|
}
|
||||||
Reference in new issue
Block a user