Test manifest toml round trip
@@ -91,7 +91,7 @@ fn remove_extra_packages(local: &LocalPackages, manifest: &Manifest) -> Result<(
Ok(())
}
-#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
+#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, PartialEq, Eq)]
pub struct Manifest {
#[serde(serialize_with = "ordered_map")]
pub requirements: HashMap<String, Range>,
@@ -165,7 +165,7 @@ impl Manifest {
#[test]
fn manifest_toml_format() {
let mut buffer = String::new();
- Manifest {
+ let mut manifest = Manifest {
requirements: [
("zzz".to_string(), Range::new("> 0.0.0".to_string())),
("aaa".to_string(), Range::new("> 0.0.0".to_string())),
@@ -194,9 +194,8 @@ fn manifest_toml_format() {
version: Version::new(0, 4, 0),
},
],
- }
- .write_to(&mut buffer)
- .unwrap();
+ };
+ manifest.write_to(&mut buffer).unwrap();
assert_eq!(
buffer,
r#"# This file was generated by Gleam
@@ -216,6 +215,9 @@ gleeunit = "~> 0.1"
zzz = "> 0.0.0"
"#
);
+ let deserialised: Manifest = toml::from_str(&buffer).unwrap();
+ manifest.packages.sort_by(|a, b| a.name.cmp(&b.name));
+ assert_eq!(deserialised, manifest);
}
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize)]
