Skip to content

Commit

Permalink
Add manifest passing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jneem committed Jan 28, 2025
1 parent 0c0a82a commit c34eb00
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions package/src/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,8 @@ impl ManifestFile {

#[cfg(test)]
mod tests {
use core::str;

use super::*;

#[test]
Expand Down Expand Up @@ -291,4 +293,30 @@ mod tests {
}
)
}

#[test]
// A bunch of example manifests, where we just check that they serialize
// without errors. No need to check the contents.
fn successful_manifest() {
let files = [
r#"{name = "foo", version = "1.0.0-alpha1+build", minimal_nickel_version = "1.9.0", authors = []}"#.as_bytes(),
r#"{name = "foo", version = "1.0.0", minimal_nickel_version = "1.9.0", authors = ["Me <[email protected]>"]}"#.as_bytes(),
r#"{name = "foo", version = "1.0.0", minimal_nickel_version = "1.9.0", authors = [], keywords = ["key"]}"#.as_bytes(),
r#"{name = "foo", version = "1.0.0", minimal_nickel_version = "1.9.0", authors = [], license = "MIT"}"#.as_bytes(),
r#"{name = "foo", version = "1.0.0", minimal_nickel_version = "1.9.0", authors = [], dependencies = { dep = 'Path "dep" }}"#.as_bytes(),
r#"{name = "foo", version = "1.0.0", minimal_nickel_version = "1.9.0", authors = [], dependencies = { dep = 'Git { url = "https://example.com" }}}"#.as_bytes(),
r#"{name = "foo", version = "1.0.0", minimal_nickel_version = "1.9.0", authors = [], dependencies = { dep = 'Git { url = "https://example.com", ref = 'Head }}}"#.as_bytes(),
r#"{name = "foo", version = "1.0.0", minimal_nickel_version = "1.9.0", authors = [], dependencies = { dep = 'Git { url = "https://example.com", ref = 'Branch "b" }}}"#.as_bytes(),
r#"{name = "foo", version = "1.0.0", minimal_nickel_version = "1.9.0", authors = [], dependencies = { dep = 'Git { url = "https://example.com", ref = 'Tag "t" }}}"#.as_bytes(),
r#"{name = "foo", version = "1.0.0", minimal_nickel_version = "1.9.0", authors = [], dependencies = { dep = 'Git { url = "https://example.com", ref = 'Commit "0c0a82aa4a05cd84ba089bdba2e6a1048058f41b" }}}"#.as_bytes(),
r#"{name = "foo", version = "1.0.0", minimal_nickel_version = "1.9.0", authors = [], dependencies = { dep = 'Git { url = "https://example.com", path = "subdir" }}}"#.as_bytes(),
// TODO: add index dependencies, once they're supported
];

for file in files {
if let Err(e) = ManifestFile::from_contents(file) {
panic!("contents {}, error {e}", str::from_utf8(file).unwrap());
}
}
}
}

0 comments on commit c34eb00

Please sign in to comment.