package types
|
|
|
|
import (
|
|
"bytes"
|
|
"testing"
|
|
|
|
"github.com/gogo/protobuf/proto"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestWriteReadMessage(t *testing.T) {
|
|
cases := []proto.Message{
|
|
&RequestEcho{"hello"},
|
|
// TODO: add the rest
|
|
}
|
|
|
|
for _, c := range cases {
|
|
buf := new(bytes.Buffer)
|
|
err := WriteMessage(c, buf)
|
|
assert.Nil(t, err)
|
|
|
|
msg := new(RequestEcho)
|
|
err = ReadMessage(buf, msg)
|
|
assert.Nil(t, err)
|
|
|
|
assert.Equal(t, c, msg)
|
|
}
|
|
}
|