creator_simctl/
shutdown.rs

1use super::{Device, Result, Validate};
2
3impl Device {
4    /// Shuts down this device. Returns an error if it isn't booted.
5    pub fn shutdown(&self) -> Result<()> {
6        self.simctl()
7            .command("shutdown")
8            .arg(&self.info().udid)
9            .output()?
10            .validate()
11    }
12}
13
14#[cfg(test)]
15mod tests {
16    use serial_test::serial;
17
18    use super::*;
19    use crate::list::DeviceState;
20    use crate::mock;
21
22    #[test]
23    #[serial]
24    fn test_shutdown() -> Result<()> {
25        mock::device()?.boot()?;
26        assert_eq!(mock::device()?.state, DeviceState::Booted);
27
28        mock::device()?.shutdown()?;
29        assert_eq!(mock::device()?.state, DeviceState::Shutdown);
30
31        Ok(())
32    }
33}