mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-17 13:05:32 +09:00
chore(repo): remove dead code and useless tests (#3375)
This commit is contained in:
1 parent
7e177a1c90
commit
1cd62eb661
1391 files changed
+783
-120415
No files matched your search
@@ -579,127 +579,3 @@ mod platform {
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
fn valid_raw_options() -> CreateShortcutOptions {
|
||||
CreateShortcutOptions {
|
||||
lnk_path: Some("C:\\Users\\Example\\Desktop\\Fluxer.lnk".to_string()),
|
||||
target: Some("C:\\Program Files\\Fluxer\\Fluxer.exe".to_string()),
|
||||
args: None,
|
||||
app_user_model_id: None,
|
||||
toast_activator_clsid: None,
|
||||
icon_path: None,
|
||||
icon_index: None,
|
||||
working_dir: None,
|
||||
description: None,
|
||||
}
|
||||
}
|
||||
|
||||
fn valid_run_value_options() -> SetRunValueOptions {
|
||||
SetRunValueOptions {
|
||||
name: Some("velopack.fluxer_desktop_canary".to_string()),
|
||||
command: Some(
|
||||
"\"C:\\Users\\Example\\AppData\\Local\\Fluxer\\Fluxer.exe\" --autostart"
|
||||
.to_string(),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn validation_rejects_missing_lnk_path() {
|
||||
let mut opts = valid_raw_options();
|
||||
opts.lnk_path = None;
|
||||
let err = validate_options(opts).expect_err("missing lnkPath should be rejected");
|
||||
assert_eq!(err.status, Status::InvalidArg);
|
||||
assert_eq!(err.reason, "lnkPath is required and must be non-empty");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn validation_rejects_empty_target() {
|
||||
let mut opts = valid_raw_options();
|
||||
opts.target = Some(String::new());
|
||||
let err = validate_options(opts).expect_err("empty target should be rejected");
|
||||
assert_eq!(err.status, Status::InvalidArg);
|
||||
assert_eq!(err.reason, "target is required and must be non-empty");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn validation_defaults_icon_index_to_zero() {
|
||||
let opts = validate_options(valid_raw_options()).expect("options should validate");
|
||||
assert_eq!(opts.icon_index, 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn validation_preserves_optional_fields() {
|
||||
let mut raw = valid_raw_options();
|
||||
raw.args = Some("--startup".to_string());
|
||||
raw.icon_path = Some("C:\\Program Files\\Fluxer\\Fluxer.exe".to_string());
|
||||
raw.icon_index = Some(2);
|
||||
raw.working_dir = Some("C:\\Program Files\\Fluxer".to_string());
|
||||
raw.description = Some("Fluxer desktop client".to_string());
|
||||
raw.app_user_model_id = Some("velopack.fluxer_desktop".to_string());
|
||||
raw.toast_activator_clsid = Some("{48EEF21B-F3AE-431E-8CF2-386FFB2143F2}".to_string());
|
||||
|
||||
let opts = validate_options(raw).expect("options should validate");
|
||||
assert_eq!(opts.args.as_deref(), Some("--startup"));
|
||||
assert_eq!(
|
||||
opts.app_user_model_id.as_deref(),
|
||||
Some("velopack.fluxer_desktop")
|
||||
);
|
||||
assert_eq!(
|
||||
opts.toast_activator_clsid.as_deref(),
|
||||
Some("{48EEF21B-F3AE-431E-8CF2-386FFB2143F2}")
|
||||
);
|
||||
assert_eq!(
|
||||
opts.icon_path.as_deref(),
|
||||
Some("C:\\Program Files\\Fluxer\\Fluxer.exe")
|
||||
);
|
||||
assert_eq!(opts.icon_index, 2);
|
||||
assert_eq!(
|
||||
opts.working_dir.as_deref(),
|
||||
Some("C:\\Program Files\\Fluxer")
|
||||
);
|
||||
assert_eq!(opts.description.as_deref(), Some("Fluxer desktop client"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn run_value_validation_rejects_missing_name() {
|
||||
let mut opts = valid_run_value_options();
|
||||
opts.name = None;
|
||||
let err = validate_run_value_options(opts).expect_err("missing name should be rejected");
|
||||
assert_eq!(err.status, Status::InvalidArg);
|
||||
assert_eq!(err.reason, "name is required and must be non-empty");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn run_value_validation_rejects_empty_command() {
|
||||
let mut opts = valid_run_value_options();
|
||||
opts.command = Some(String::new());
|
||||
let err = validate_run_value_options(opts).expect_err("empty command should be rejected");
|
||||
assert_eq!(err.status, Status::InvalidArg);
|
||||
assert_eq!(err.reason, "command is required and must be non-empty");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn run_value_validation_preserves_fields() {
|
||||
let opts =
|
||||
validate_run_value_options(valid_run_value_options()).expect("options should validate");
|
||||
assert_eq!(opts.name, "velopack.fluxer_desktop_canary");
|
||||
assert_eq!(
|
||||
opts.command,
|
||||
"\"C:\\Users\\Example\\AppData\\Local\\Fluxer\\Fluxer.exe\" --autostart"
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
#[test]
|
||||
fn non_windows_worker_preserves_stub_error_contract() {
|
||||
let opts = validate_options(valid_raw_options()).expect("options should validate");
|
||||
let err = platform::create_shortcut(&opts).expect_err("non-Windows should fail");
|
||||
assert_eq!(err.status, Status::GenericFailure);
|
||||
assert_eq!(err.reason, "win-shell not supported on this platform");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user