Skip to content
Snippets Groups Projects
Commit 4d28b415 authored by Daniel Czerwonk's avatar Daniel Czerwonk
Browse files

added tests for conn mock

parent ce6bb9ee
No related branches found
No related tags found
No related merge requests found
......@@ -27,6 +27,6 @@ func (m *MockConn) Read(b []byte) (n int, err error) {
count = len(m.Bytes)
}
copy(m.Bytes[0:count], b)
copy(b, m.Bytes[0:count])
return count, nil
}
package testing
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestWrite(t *testing.T) {
m := &MockConn{}
payload := []byte{1, 2, 3}
m.Write(payload)
assert.Equal(t, payload, m.Bytes)
}
func TestRead(t *testing.T) {
m := &MockConn{}
payload := []byte{1, 2, 3}
m.Bytes = payload
buffer := make([]byte, 4)
m.Read(buffer)
assert.Equal(t, payload, buffer[:3])
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment