2021-02-02 12:05:47 +01:00
|
|
|
package ndt7
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/gorilla/websocket"
|
|
|
|
)
|
|
|
|
|
2022-05-30 23:14:07 +02:00
|
|
|
type mockableWSConn struct {
|
2021-02-02 12:05:47 +01:00
|
|
|
NextReaderMsgType int
|
|
|
|
NextReaderErr error
|
|
|
|
NextReaderReader func() io.Reader
|
|
|
|
ReadDeadlineErr error
|
|
|
|
WriteDeadlineErr error
|
|
|
|
WritePreparedMessageErr error
|
|
|
|
}
|
|
|
|
|
2022-05-30 23:14:07 +02:00
|
|
|
func (c *mockableWSConn) NextReader() (int, io.Reader, error) {
|
2021-02-02 12:05:47 +01:00
|
|
|
var reader io.Reader
|
|
|
|
if c.NextReaderReader != nil {
|
|
|
|
reader = c.NextReaderReader()
|
|
|
|
}
|
|
|
|
return c.NextReaderMsgType, reader, c.NextReaderErr
|
|
|
|
}
|
|
|
|
|
2022-05-30 23:14:07 +02:00
|
|
|
func (c *mockableWSConn) SetReadDeadline(time.Time) error {
|
2021-02-02 12:05:47 +01:00
|
|
|
return c.ReadDeadlineErr
|
|
|
|
}
|
|
|
|
|
2022-05-30 23:14:07 +02:00
|
|
|
func (c *mockableWSConn) SetReadLimit(int64) {}
|
2021-02-02 12:05:47 +01:00
|
|
|
|
2022-05-30 23:14:07 +02:00
|
|
|
func (c *mockableWSConn) SetWriteDeadline(time.Time) error {
|
2021-02-02 12:05:47 +01:00
|
|
|
return c.WriteDeadlineErr
|
|
|
|
}
|
|
|
|
|
2022-05-30 23:14:07 +02:00
|
|
|
func (c *mockableWSConn) WritePreparedMessage(*websocket.PreparedMessage) error {
|
2021-02-02 12:05:47 +01:00
|
|
|
return c.WritePreparedMessageErr
|
|
|
|
}
|