fixed tests
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Jake Hillion 2020-11-02 17:29:02 +00:00
parent 22b5cc74e1
commit a731c71ed6
3 changed files with 10 additions and 4 deletions

View File

@ -1,5 +1,7 @@
package mocks
import "time"
type MockPerfectBiConn struct {
directionA chan byte
directionB chan byte
@ -25,6 +27,10 @@ type MockPerfectConn struct {
outbound chan byte
}
func (c MockPerfectConn) SetWriteDeadline(time.Time) error {
return nil
}
func (c MockPerfectConn) Read(p []byte) (n int, err error) {
for i := range p {
if i == 0 {

View File

@ -99,7 +99,7 @@ func (f *Flow) consumeMarshalled(data []byte) error {
binary.LittleEndian.PutUint32(prefixedData, uint32(len(data)))
copy(prefixedData[4:], data)
err := f.conn.SetWriteDeadline(time.Now().Add(5*time.Second))
err := f.conn.SetWriteDeadline(time.Now().Add(5 * time.Second))
if err != nil {
return err
}

View File

@ -17,7 +17,7 @@ func TestFlow_Consume(t *testing.T) {
t.Run("Length", func(t *testing.T) {
testConn := mocks.NewMockPerfectBiConn(100)
flowA := Flow{conn: testConn.SideA()}
flowA := Flow{conn: testConn.SideA(), isAlive: true}
err := flowA.Consume(testPacket, testMac)
require.Nil(t, err)
@ -41,7 +41,7 @@ func TestFlow_Produce(t *testing.T) {
t.Run("Length", func(t *testing.T) {
testConn := mocks.NewMockPerfectBiConn(100)
flowA := Flow{conn: testConn.SideA()}
flowA := Flow{conn: testConn.SideA(), isAlive: true}
_, err := testConn.SideB().Write(testMarshalled)
require.Nil(t, err)
@ -54,7 +54,7 @@ func TestFlow_Produce(t *testing.T) {
t.Run("Value", func(t *testing.T) {
testConn := mocks.NewMockPerfectBiConn(100)
flowA := Flow{conn: testConn.SideA()}
flowA := Flow{conn: testConn.SideA(), isAlive: true}
_, err := testConn.SideB().Write(testMarshalled)
require.Nil(t, err)