PHP Classes

File: pipe_test.go

Recommend this page to a friend!
  Classes of Wolfy-J   goridge   pipe_test.go   Download  
File: pipe_test.go
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: goridge
Run Golang code from PHP calling its RPC server
Author: By
Last change:
Date: 6 years ago
Size: 1,070 bytes
 

Contents

Class file image Download
package goridge import ( "bytes" "github.com/stretchr/testify/assert" "testing" ) func TestClosePipeRelay(t *testing.T) { r := NewPipeRelay(&connMock{}, &connMock{}) assert.Nil(t, r.Close()) } func TestPipeReceive(t *testing.T) { conn := &connMock{} r := NewPipeRelay(conn, &connMock{}) assert.Nil(t, r.Close()) prefix := NewPrefix().WithFlag(PayloadControl).WithSize(5) payload := []byte("hello") conn.expect(read, prefix[:]) conn.expect(read, payload) data, p, err := r.Receive() assert.Nil(t, err) assert.True(t, p.HasFlag(PayloadControl)) assert.Equal(t, uint64(5), p.Size()) assert.Equal(t, 0, bytes.Compare(data, payload)) assert.Empty(t, 0, conn.leftSegments()) } func TestPipeSend(t *testing.T) { conn := &connMock{} r := NewPipeRelay(&connMock{}, conn) assert.Nil(t, r.Close()) prefix := NewPrefix().WithFlag(PayloadControl).WithSize(5) payload := []byte("hello") conn.expect(write, prefix[:]) conn.expect(write, payload) err := r.Send(payload, prefix.Flags()) assert.Nil(t, err) assert.Empty(t, 0, conn.leftSegments()) }