summaryrefslogtreecommitdiff
path: root/pkg/worker/sync_worker_test.go
blob: 64580f9fe2d2cae13227b3214253d46215d77ece (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package worker

import (
	"os/exec"
	"testing"

	"github.com/spiral/roadrunner/v2/pkg/payload"
	"github.com/stretchr/testify/assert"
)

func Test_NotStarted_String(t *testing.T) {
	cmd := exec.Command("php", "tests/client.php", "echo", "pipes")

	w, _ := InitBaseWorker(cmd)
	assert.Contains(t, w.String(), "php tests/client.php echo pipes")
	assert.Contains(t, w.String(), "inactive")
	assert.Contains(t, w.String(), "numExecs: 0")
}

func Test_NotStarted_Exec(t *testing.T) {
	cmd := exec.Command("php", "tests/client.php", "echo", "pipes")

	w, _ := InitBaseWorker(cmd)

	sw := From(w)

	res, err := sw.Exec(&payload.Payload{Body: []byte("hello")})

	assert.Error(t, err)
	assert.Nil(t, res)

	assert.Contains(t, err.Error(), "Process is not ready (inactive)")
}