mirror of
https://github.com/redhat-developer/odo.git
synced 2025-10-19 03:06:19 +03:00
* Ignore devstate when existing process name is not odo * Delete orphan devstate files with odo delete component * Update unit tests * Create fake system * Add unit tests for odo delete component * Integration tests for odo dev * Troubleshooting * First process on Windows is 4 * Use go-ps lib for pidExists
42 lines
691 B
Go
42 lines
691 B
Go
package system
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"github.com/mitchellh/go-ps"
|
|
)
|
|
|
|
type Fake struct {
|
|
ProcessId int
|
|
ParentId int
|
|
// PidTable is a map of pid => executable name of existing processes
|
|
PidTable map[int]string
|
|
}
|
|
|
|
func (o Fake) Pid() int {
|
|
return o.ProcessId
|
|
}
|
|
|
|
func (o Fake) PPid() int {
|
|
return o.ParentId
|
|
}
|
|
|
|
func (o Fake) Executable() string {
|
|
return o.PidTable[o.ProcessId]
|
|
}
|
|
|
|
var _ System = Fake{}
|
|
|
|
func (o Fake) FindProcess(pid int) (ps.Process, error) {
|
|
if _, found := o.PidTable[pid]; found {
|
|
o.ProcessId = pid
|
|
return o, nil
|
|
}
|
|
return nil, errors.New("no process found")
|
|
}
|
|
|
|
func (o Fake) PidExists(pid int) (bool, error) {
|
|
_, found := o.PidTable[pid]
|
|
return found, nil
|
|
}
|