diff options
author | Valery Piashchynski <[email protected]> | 2020-12-14 12:48:23 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2020-12-14 12:48:23 +0300 |
commit | 8203dc4d76624f4fceddff49b8a1aba9d525fc73 (patch) | |
tree | 0243010b2c7dd26dcd87e7965da4affe80731dd2 /protocol_test.go | |
parent | 673da74925dee5c62064d3304289ae81cb499217 (diff) |
Move to goridge3
Diffstat (limited to 'protocol_test.go')
-rwxr-xr-x | protocol_test.go | 47 |
1 files changed, 0 insertions, 47 deletions
diff --git a/protocol_test.go b/protocol_test.go deleted file mode 100755 index 396ce992..00000000 --- a/protocol_test.go +++ /dev/null @@ -1,47 +0,0 @@ -package roadrunner - -import ( - "testing" - - "github.com/pkg/errors" - "github.com/spiral/goridge/v2" - "github.com/stretchr/testify/assert" -) - -type relayMock struct { - error bool - payload string -} - -func (r *relayMock) Send(data []byte, flags byte) (err error) { - if r.error { - return errors.New("send error") - } - - return nil -} - -func (r *relayMock) Receive() (data []byte, p goridge.Prefix, err error) { - return []byte(r.payload), goridge.NewPrefix().WithFlag(goridge.PayloadControl), nil -} - -func (r *relayMock) Close() error { - return nil -} - -func Test_Protocol_Errors(t *testing.T) { - err := sendControl(&relayMock{}, make(chan int)) - assert.Error(t, err) -} - -func Test_Protocol_FetchPID(t *testing.T) { - pid, err := fetchPID(&relayMock{error: false, payload: "{\"pid\":100}"}) - assert.NoError(t, err) - assert.Equal(t, int64(100), pid) - - _, err = fetchPID(&relayMock{error: true, payload: "{\"pid\":100}"}) - assert.Error(t, err) - - _, err = fetchPID(&relayMock{error: false, payload: "{\"pid:100"}) - assert.Error(t, err) -} |