Skip to content

Commit

Permalink
add spm repo parsing unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kattouf committed Jun 3, 2024
1 parent 0fecc0b commit d67999b
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/backend/spm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,36 @@ impl SwiftPackageRepo {
}
}

#[cfg(test)]
mod tests {
use pretty_assertions::assert_str_eq;
use test_log::test;

use super::*;

#[test]
fn test_spm_repo_init_by_shorthand() {
let package_name = "nicklockwood/SwiftFormat";
let package_repo = SwiftPackageRepo::new(package_name).unwrap();
assert_str_eq!(
package_repo.url.as_str(),
"https://github.com/nicklockwood/SwiftFormat.git"
);
assert_str_eq!(package_repo.shorthand, "nicklockwood/SwiftFormat");
}

#[test]
fn test_spm_repo_init_by_url() {
let package_name = "https://github.com/nicklockwood/SwiftFormat.git";
let package_repo = SwiftPackageRepo::new(package_name).unwrap();
assert_str_eq!(
package_repo.url.as_str(),
"https://github.com/nicklockwood/SwiftFormat.git"
);
assert_str_eq!(package_repo.shorthand, "nicklockwood/SwiftFormat");
}
}

/// https://developer.apple.com/documentation/packagedescription
#[derive(Deserialize)]
struct PackageDescription {
Expand Down

0 comments on commit d67999b

Please sign in to comment.