path_info: check for and resolve symlink
This commit is contained in:
parent
0e97d11745
commit
14d6e9d29e
3 changed files with 33 additions and 4 deletions
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue