Skip to content

Commit

Permalink
test: fix test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
tikazyq committed Nov 22, 2024
1 parent aa1b01b commit eee10ea
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions core/task/handler/runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import (
"encoding/json"
"fmt"
"github.com/apex/log"
"github.com/crawlab-team/crawlab/core/utils"
"io"
"os"
"syscall"
"testing"
"time"

Expand Down Expand Up @@ -127,15 +126,14 @@ func TestRunner_Cancel(t *testing.T) {
runner.pid = runner.cmd.Process.Pid

// Test cancel
err = runner.Cancel(true)
assert.NoError(t, err)
go func() {
err = runner.Cancel(true)
assert.NoError(t, err)
}()

// Verify process was killed
// Wait a short time for the process to be killed
time.Sleep(100 * time.Millisecond)

process, err := os.FindProcess(runner.pid)
require.NoError(t, err)
err = process.Signal(syscall.Signal(0))
assert.Error(t, err) // Process should not exist
exists := utils.ProcessIdExists(runner.pid)
assert.False(t, exists)
}

0 comments on commit eee10ea

Please sign in to comment.