aboutsummaryrefslogtreecommitdiff
path: root/src/utils/mod.rs
diff options
context:
space:
mode:
authornotgne22020-10-01 12:43:33 -0700
committernotgne22020-10-01 12:43:33 -0700
commitea5aab76849ba3ce9ff2b7eba2a391d4ea33fa3a (patch)
treef59aa113c111e87d0df9a3028a98ff6237177f0e /src/utils/mod.rs
parent05a997558400f093c7278decd6300ce09044227b (diff)
Improve nix copy stuff
Diffstat (limited to '')
-rw-r--r--src/utils/mod.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/utils/mod.rs b/src/utils/mod.rs
index 5802627..30201c3 100644
--- a/src/utils/mod.rs
+++ b/src/utils/mod.rs
@@ -136,3 +136,27 @@ pub async fn make_deploy_data<'a>(
current_exe,
})
}
+
+pub fn deploy_path_to_activate_path_str(
+ deploy_path: &std::path::Path,
+) -> Result<String, Box<dyn std::error::Error>> {
+ Ok(format!(
+ "{}/activate",
+ deploy_path
+ .parent()
+ .ok_or("Deploy path too short")?
+ .to_str()
+ .ok_or("Deploy path is not valid utf8")?
+ .to_owned()
+ ))
+}
+
+#[test]
+fn test_activate_path_generation() {
+ match deploy_path_to_activate_path_str(&std::path::PathBuf::from(
+ "/blah/blah/deploy-rs/bin/deploy",
+ )) {
+ Err(_) => panic!(""),
+ Ok(x) => assert_eq!(x, "/blah/blah/deploy-rs/bin/activate".to_string()),
+ }
+}