Skip to content
Merged
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
26 changes: 20 additions & 6 deletions tests/plugins/test_marketplace_resolution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,20 @@ fn write_file(path: &Path, contents: &str) {
fs::write(path, contents).expect("write file");
}

fn path_to_file_url(path: &Path) -> String {
// Convert path to forward slashes for cross-platform compatibility
let path_str = path.display().to_string().replace('\\', "/");

// file:// URLs require three slashes total on all platforms:
// - Unix: file:///path/to/repo
// - Windows: file:///C:/path/to/repo
if path_str.starts_with('/') {
format!("file://{path_str}")
} else {
format!("file:///{path_str}")
}
}

fn create_marketplace_with_plugin_root(workspace: &Path) -> String {
let repo_path = workspace.join("marketplace");
let marketplace_dir = repo_path.join(".claude-plugin");
Expand Down Expand Up @@ -145,6 +159,7 @@ fn install_supports_git_source_object() {
fs::create_dir_all(&marketplace_dir).expect("create marketplace dir");

let plugin_repo = create_external_plugin_repo(workspace, "external-source");
let file_url = path_to_file_url(&plugin_repo);

let marketplace_json = format!(
r#"{{
Expand All @@ -155,13 +170,12 @@ fn install_supports_git_source_object() {
"name": "external-plugin",
"source": {{
"source": "git",
"url": "file://{}"
"url": "{file_url}"
}},
"description": "External plugin source"
}}
]
}}"#,
plugin_repo.display()
}}"#
);

write_file(&marketplace_dir.join("marketplace.json"), &marketplace_json);
Expand Down Expand Up @@ -189,6 +203,7 @@ fn update_external_plugin_detects_up_to_date() {
fs::create_dir_all(&marketplace_dir).expect("create marketplace dir");

let plugin_repo = create_external_plugin_repo(workspace, "external-update-source");
let file_url = path_to_file_url(&plugin_repo);

let marketplace_json = format!(
r#"{{
Expand All @@ -199,12 +214,11 @@ fn update_external_plugin_detects_up_to_date() {
"name": "external-plugin",
"source": {{
"source": "git",
"url": "file://{}"
"url": "{file_url}"
}}
}}
]
}}"#,
plugin_repo.display()
}}"#
);

write_file(&marketplace_dir.join("marketplace.json"), &marketplace_json);
Expand Down
Loading