path_info: check for and resolve symlink

This commit is contained in:
cy 2025-05-04 01:48:13 -04:00
parent 0e97d11745
commit 14d6e9d29e
3 changed files with 33 additions and 4 deletions

View file

@ -1,6 +1,8 @@
use nixcp::path_info::PathInfo;
use std::path::PathBuf;
use tempfile::TempDir;
use crate::common::{HELLO, HELLO_DRV, HELLO_PATH};
mod common;
@ -25,6 +27,23 @@ async fn path_info_from_path() {
assert_eq!(path_info.path.to_string(), HELLO_DRV);
}
#[tokio::test]
async fn path_info_symlink() {
let ctx = common::context();
let temp_path = TempDir::new().unwrap();
let link_path = temp_path.path().join("result");
// symlink at ./result (like `nix build`)
std::os::unix::fs::symlink(HELLO_PATH, &link_path).unwrap();
// should resolve symlink
let path_info = PathInfo::from_derivation(&link_path, &ctx.store)
.await
.expect("get pathinfo from package");
assert_eq!(path_info.path.to_string(), HELLO_DRV);
}
#[tokio::test]
async fn closure() {
let ctx = common::context();