Skip to content

Commit

Permalink
fix: correctly serialize IndirectFlake (#5)
Browse files Browse the repository at this point in the history
* fix: correctly serialize IndirectFlake

Currently the string "{id}" is being used rather than the variable id

* Update crates/runix/src/flake_ref.rs

Co-authored-by: notgne2 <[email protected]>

---------

Co-authored-by: notgne2 <[email protected]>
  • Loading branch information
mkenigs and notgne2 authored Mar 1, 2023
1 parent 0d1bd43 commit 3112401
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions crates/runix/src/flake_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ impl ToFlakeRef {
unpack: _,
nar_hash: _,
} => todo!(),
ToFlakeRef::Indirect(IndirectFlake { id: _ }) => {
Url::parse("flake:{id}").expect("Failed to create indirect reference")
ToFlakeRef::Indirect(IndirectFlake { id }) => {
Url::parse(&format!("flake:{id}")).expect("Failed to create indirect reference")
},
};
Ok(url)
Expand Down Expand Up @@ -445,7 +445,7 @@ mod tests {
})
}

/// Ensure that a path flake ref serializes without inforation loss
/// Ensure that a path flake ref serializes without information loss
#[test]
fn path_to_from_url() {
let flake_ref = ToFlakeRef::Path {
Expand Down Expand Up @@ -479,7 +479,7 @@ mod tests {
)
}

/// Ensure that a github flake ref serializes without inforation loss
/// Ensure that a github flake ref serializes without information loss
#[test]
fn github_to_from_url() {
let flake_ref = ToFlakeRef::GitHub(GitService {
Expand All @@ -495,4 +495,17 @@ mod tests {

assert_eq!(flake_ref, parsed)
}

/// Ensure that an indirect flake ref serializes without information loss
#[test]
fn indirect_to_from_url() {
let flake_ref = ToFlakeRef::Indirect(IndirectFlake {
id: "nixpkgs-flox".into(),
});

let parsed = ToFlakeRef::from_url(&flake_ref.to_url().expect("should serialize to url"))
.expect("should deserialize from url");

assert_eq!(flake_ref, parsed)
}
}

0 comments on commit 3112401

Please sign in to comment.