creator_simctl/
install.rs

1use std::path::Path;
2
3use super::{Device, Result, Validate};
4
5impl Device {
6    /// Installs an .app folder from the given path onto this device. If the
7    /// app (or an earlier version) already existed on this device, its app
8    /// container (see [`Device::get_app_container`]) will be
9    /// overwritten while the other containers remain unchanged (i.e. data
10    /// persists between upgrades).
11    pub fn install(&self, path: &Path) -> Result<()> {
12        self.simctl()
13            .command("install")
14            .arg(&self.udid)
15            .arg(&path)
16            .output()?
17            .validate()
18    }
19}
20
21#[cfg(test)]
22mod tests {
23    use serial_test::serial;
24
25    use super::*;
26    use crate::mock;
27
28    #[test]
29    #[serial]
30    fn test_install() -> Result<()> {
31        let mut path = Path::new(env!("CARGO_MANIFEST_DIR")).to_path_buf();
32        path.push("tests/Example.app");
33
34        mock::device()?.boot()?;
35        mock::device()?.install(&path)?;
36        mock::device()?.uninstall("com.glacyr.simctl.Example")?;
37        mock::device()?.shutdown()?;
38
39        Ok(())
40    }
41}