use k9::assert_equal;
use iocore::{Error, Path, User, Result};
fn home_path() -> String {
User::id().unwrap().home().unwrap()
}
fn home_tests_path() -> Path {
let folder = Path::new("~/.tmp/tests").try_canonicalize();
assert!(folder.to_string().starts_with(home_path().as_str()));
folder
}
#[test]
fn test_collapse() -> Result<()> {
let tests_path = home_tests_path();
let sub_path = tests_path.join("subfolder").join("file");
sub_path.write_unchecked(&[]);
assert_equal!(sub_path.collapse(), Path::new("~/.tmp/tests/subfolder/file"));
Ok(())
}