Files
crawlab/core/utils/process_test.go
2024-11-22 17:43:59 +08:00

21 lines
456 B
Go

package utils
import (
"os"
"testing"
"github.com/stretchr/testify/assert"
)
func TestProcessIdExists(t *testing.T) {
t.Run("existing process", func(t *testing.T) {
currentPid := os.Getpid()
assert.True(t, ProcessIdExists(currentPid), "should detect current process")
})
t.Run("non-existent process", func(t *testing.T) {
invalidPid := 99999999
assert.False(t, ProcessIdExists(invalidPid), "should not detect non-existent process")
})
}