From 78fee1f14e39bbb36204737d2fc6be985614911d Mon Sep 17 00:00:00 2001 From: Wolfy-J Date: Wed, 6 Jun 2018 16:34:31 +0300 Subject: more tests --- server_test.go | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) (limited to 'server_test.go') diff --git a/server_test.go b/server_test.go index 3f283dce..bb31bada 100644 --- a/server_test.go +++ b/server_test.go @@ -1 +1,57 @@ package roadrunner + +import ( + "testing" + "github.com/stretchr/testify/assert" + "runtime" + "time" +) + +func TestServer_PipesEcho(t *testing.T) { + srv := NewServer(&ServerConfig{ + Command: "php php-src/tests/client.php echo pipes", + Relay: "pipes", + Pool: &Config{ + NumWorkers: uint64(runtime.NumCPU()), + AllocateTimeout: time.Second, + DestroyTimeout: time.Second, + }, + }, nil) + defer srv.Stop() + + assert.NoError(t, srv.Start()) + + res, err := srv.Exec(&Payload{Body: []byte("hello")}) + + assert.NoError(t, err) + assert.NotNil(t, res) + assert.NotNil(t, res.Body) + assert.Nil(t, res.Context) + + assert.Equal(t, "hello", res.String()) +} + +func TestServer_SocketEcho(t *testing.T) { + srv := NewServer(&ServerConfig{ + Command: "php php-src/tests/client.php echo tcp", + Relay: "tcp://:9007", + RelayTimeout: 10 * time.Second, + Pool: &Config{ + NumWorkers: uint64(runtime.NumCPU()), + AllocateTimeout: time.Second, + DestroyTimeout: time.Second, + }, + }, nil) + defer srv.Stop() + + assert.NoError(t, srv.Start()) + + res, err := srv.Exec(&Payload{Body: []byte("hello")}) + + assert.NoError(t, err) + assert.NotNil(t, res) + assert.NotNil(t, res.Body) + assert.Nil(t, res.Context) + + assert.Equal(t, "hello", res.String()) +} -- cgit v1.2.3