diff options
author | Wolfy-J <[email protected]> | 2018-06-06 16:34:31 +0300 |
---|---|---|
committer | Wolfy-J <[email protected]> | 2018-06-06 16:34:31 +0300 |
commit | 78fee1f14e39bbb36204737d2fc6be985614911d (patch) | |
tree | 2e6c51d3ef6b7bad64eeff9ea4693a0967dc83b7 /server_test.go | |
parent | 8a22b1bdda462075bfc56f17110eb3c0dc1f3f79 (diff) |
more tests
Diffstat (limited to 'server_test.go')
-rw-r--r-- | server_test.go | 56 |
1 files changed, 56 insertions, 0 deletions
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()) +} |