mirror of
https://github.com/containers/youki
synced 2024-11-23 17:32:15 +01:00
add tests of ContainerStatus.
This commit is contained in:
parent
3e242b91f1
commit
c7fce3f0f3
@ -24,6 +24,7 @@ pub enum ContainerStatus {
|
||||
// The container process has paused
|
||||
Paused,
|
||||
}
|
||||
|
||||
impl Default for ContainerStatus {
|
||||
fn default() -> Self {
|
||||
ContainerStatus::Creating
|
||||
@ -157,3 +158,58 @@ impl State {
|
||||
container_root.join(Self::STATE_FILE_PATH)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_creating_status() {
|
||||
let cstatus = ContainerStatus::default();
|
||||
assert!(!cstatus.can_start());
|
||||
assert!(!cstatus.can_delete());
|
||||
assert!(!cstatus.can_kill());
|
||||
assert!(!cstatus.can_pause());
|
||||
assert!(!cstatus.can_resume());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_create_status() {
|
||||
let cstatus = ContainerStatus::Created;
|
||||
assert!(cstatus.can_start());
|
||||
assert!(!cstatus.can_delete());
|
||||
assert!(cstatus.can_kill());
|
||||
assert!(!cstatus.can_pause());
|
||||
assert!(!cstatus.can_resume());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_running_status() {
|
||||
let cstatus = ContainerStatus::Running;
|
||||
assert!(!cstatus.can_start());
|
||||
assert!(!cstatus.can_delete());
|
||||
assert!(cstatus.can_kill());
|
||||
assert!(cstatus.can_pause());
|
||||
assert!(!cstatus.can_resume());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_stopped_status() {
|
||||
let cstatus = ContainerStatus::Stopped;
|
||||
assert!(!cstatus.can_start());
|
||||
assert!(cstatus.can_delete());
|
||||
assert!(!cstatus.can_kill());
|
||||
assert!(!cstatus.can_pause());
|
||||
assert!(!cstatus.can_resume());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_paused_status() {
|
||||
let cstatus = ContainerStatus::Paused;
|
||||
assert!(!cstatus.can_start());
|
||||
assert!(!cstatus.can_delete());
|
||||
assert!(cstatus.can_kill());
|
||||
assert!(!cstatus.can_pause());
|
||||
assert!(cstatus.can_resume());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user