mirror of
https://codeberg.org/Toasterson/ips.git
synced 2026-04-10 13:20:42 +00:00
Reorder struct fields for consistency and align with Rust formatting standards.
This commit is contained in:
parent
d2d1c297cc
commit
a921c99eb6
1 changed files with 29 additions and 23 deletions
|
|
@ -125,10 +125,6 @@ pub struct UpdateLogInfo {
|
|||
/// Catalog attributes
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct CatalogAttrs {
|
||||
/// Optional signature information
|
||||
#[serde(rename = "_SIGNATURE", skip_serializing_if = "Option::is_none")]
|
||||
pub signature: Option<HashMap<String, String>>,
|
||||
|
||||
/// Creation timestamp in ISO-8601 'basic format' date in UTC
|
||||
pub created: String,
|
||||
|
||||
|
|
@ -153,6 +149,10 @@ pub struct CatalogAttrs {
|
|||
|
||||
/// Catalog version
|
||||
pub version: u32,
|
||||
|
||||
/// Optional signature information
|
||||
#[serde(rename = "_SIGNATURE", skip_serializing_if = "Option::is_none")]
|
||||
pub signature: Option<HashMap<String, String>>,
|
||||
}
|
||||
|
||||
impl CatalogAttrs {
|
||||
|
|
@ -206,13 +206,13 @@ pub struct PackageVersionEntry {
|
|||
/// Catalog part (base, dependency, summary)
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct CatalogPart {
|
||||
/// Optional signature information
|
||||
#[serde(rename = "_SIGNATURE", skip_serializing_if = "Option::is_none")]
|
||||
pub signature: Option<HashMap<String, String>>,
|
||||
|
||||
/// Packages by publisher and stem
|
||||
#[serde(flatten)]
|
||||
pub packages: HashMap<String, HashMap<String, Vec<PackageVersionEntry>>>,
|
||||
|
||||
/// Optional signature information
|
||||
#[serde(rename = "_SIGNATURE", skip_serializing_if = "Option::is_none")]
|
||||
pub signature: Option<HashMap<String, String>>,
|
||||
}
|
||||
|
||||
impl CatalogPart {
|
||||
|
|
@ -280,9 +280,7 @@ impl CatalogPart {
|
|||
// Try to parse the JSON directly
|
||||
match serde_json::from_reader(json) {
|
||||
Ok(part) => Ok(part),
|
||||
Err(e) => {
|
||||
Err(CatalogError::JsonSerializationError(e))
|
||||
}
|
||||
Err(e) => Err(CatalogError::JsonSerializationError(e)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -322,12 +320,12 @@ pub struct PackageUpdateEntry {
|
|||
/// Update log
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct UpdateLog {
|
||||
/// Updates by publisher and stem
|
||||
pub updates: HashMap<String, HashMap<String, Vec<PackageUpdateEntry>>>,
|
||||
|
||||
/// Optional signature information
|
||||
#[serde(rename = "_SIGNATURE", skip_serializing_if = "Option::is_none")]
|
||||
pub signature: Option<HashMap<String, String>>,
|
||||
|
||||
/// Updates by publisher and stem
|
||||
pub updates: HashMap<String, HashMap<String, Vec<PackageUpdateEntry>>>,
|
||||
}
|
||||
|
||||
impl UpdateLog {
|
||||
|
|
@ -596,7 +594,9 @@ mod tests {
|
|||
#[test]
|
||||
fn test_load_sample_catalog() {
|
||||
// Path is relative to the crate root (libips)
|
||||
let path = PathBuf::from("../sample_data/sample-repo/publisher/openindiana.org/catalog/catalog.base.C");
|
||||
let path = PathBuf::from(
|
||||
"../sample_data/sample-repo/publisher/openindiana.org/catalog/catalog.base.C",
|
||||
);
|
||||
|
||||
// Only run this test if the sample data exists
|
||||
if path.exists() {
|
||||
|
|
@ -607,16 +607,22 @@ mod tests {
|
|||
|
||||
// Verify we loaded the correct data structure
|
||||
// The sample file has "openindiana.org" as a key
|
||||
assert!(part.packages.contains_key("openindiana.org"), "Catalog should contain openindiana.org publisher");
|
||||
assert!(
|
||||
part.packages.contains_key("openindiana.org"),
|
||||
"Catalog should contain openindiana.org publisher"
|
||||
);
|
||||
|
||||
let packages = part.packages.get("openindiana.org").unwrap();
|
||||
println!("Found {} packages for openindiana.org", packages.len());
|
||||
assert!(packages.len() > 0, "Should have loaded packages");
|
||||
},
|
||||
}
|
||||
Err(e) => panic!("Failed to load catalog part: {}", e),
|
||||
}
|
||||
} else {
|
||||
println!("Sample data not found at {:?}, skipping test. This is expected in some CI environments.", path);
|
||||
println!(
|
||||
"Sample data not found at {:?}, skipping test. This is expected in some CI environments.",
|
||||
path
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue