Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ pub struct MountSpec {
pub enum MountProvider {
Icloud,
GoogleDrive,
#[serde(rename = "onedrive", alias = "one-drive")]
OneDrive,
}

Expand Down Expand Up @@ -812,4 +813,32 @@ windows = "none"
let decoded: Config = toml::from_str(&encoded).unwrap();
assert_eq!(decoded, config);
}

#[test]
fn onedrive_accepts_legacy_spelling_and_serializes_canonical_name() {
for provider in ["onedrive", "one-drive"] {
let config: Config = toml::from_str(&format!(
"[mounts.work]\nprovider = \"{provider}\"\naccount = \"business\"\n"
))
.unwrap();
assert_eq!(config.validate(), Ok(()));
assert_eq!(
config.mounts["work"].provider,
Some(MountProvider::OneDrive)
);
assert_eq!(
config.mounts["work"].account,
Some(OneDriveAccount::Business)
);

let encoded = toml::to_string_pretty(&config).unwrap();
let document: toml::Value = toml::from_str(&encoded).unwrap();
assert_eq!(
document["mounts"]["work"]["provider"].as_str(),
Some("onedrive")
);
let decoded: Config = toml::from_str(&encoded).unwrap();
assert_eq!(decoded, config);
}
}
}
28 changes: 28 additions & 0 deletions tests/config_mounts_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,34 @@ impl Fixture {
}
}

#[test]
fn completions_accept_documented_and_legacy_onedrive_configs() {
let temp = TempDir::new("onedrive-config");
let config = temp.path().join("config.toml");
for provider in ["onedrive", "one-drive"] {
fs::write(
&config,
format!(
"[mounts]\nonedrive-work = {{ provider = \"{provider}\", account = \"business\" }}\n"
),
)
.unwrap();
let output = cj(temp.path(), temp.path())
.arg("-C")
.arg(&config)
.args(["completions", "bash"])
.output()
.unwrap();
assert_success(&output);
assert!(output.stderr.is_empty());
assert!(
String::from_utf8(output.stdout)
.unwrap()
.contains("'onedrive-work'")
);
}
}

#[test]
fn resolves_aliases_and_explicit_mounts_with_resolver_controls() {
let fixture = Fixture::new("configured-destinations");
Expand Down
Loading