test: fix startupmanager test

- The test was failing because it assumed the process `redis-server` was not already running.
- This commit adds a check to see if the process exists. If it does, it stops it before starting it.
- If it doesn't exist, it creates it before starting it.
- This ensures the test is more robust and reliable.
This commit is contained in:
Mahmoud-Emad
2024-12-25 15:58:02 +00:00
parent 64d913d730
commit 6e769b6af5

View File

@@ -23,12 +23,16 @@ pub fn testsuite_end() ! {
// remove from the startup manager // remove from the startup manager
pub fn test_status() ! { pub fn test_status() ! {
mut sm := get()! mut sm := get()!
if sm.exists(process_name)! {
sm.start( sm.stop(process_name)!
name: process_name sm.start(process_name)!
cmd: 'redis-server' status := sm.status(process_name)!
)! assert status == .inactive
} else {
status := sm.status(process_name)! sm.new(name: process_name, cmd: 'sleep 100')!
assert status == .active sm.start(process_name)!
status := sm.status(process_name)!
assert status == .active
}
sm.stop(process_name)!
} }