FILE / ScuroNeko/mtg

mtglib/internal/relay/init_test.go

Исходный файл и его история в репозитории.
FILE ec4f0656fb7cce2de8b57e848b1eb03c7b520014
Files
mtg/mtglib/internal/relay/init_test.go
T
2021-04-09 14:35:04 +03:00

50 lines
681 B
Go

package relay_test
import (
"bytes"
"io"
"sync"
)
type loggerMock struct{}
func (l loggerMock) Printf(format string, args ...interface{}) {}
type rwcMock struct {
bytes.Buffer
closed bool
mutex sync.Mutex
}
func (r *rwcMock) Read(p []byte) (int, error) {
r.mutex.Lock()
defer r.mutex.Unlock()
if r.closed {
return 0, io.EOF
}
return r.Buffer.Read(p) // nolint: wrapcheck
}
func (r *rwcMock) Write(p []byte) (int, error) {
r.mutex.Lock()
defer r.mutex.Unlock()
if r.closed {
return 0, io.EOF
}
return r.Buffer.Write(p) // nolint: wrapcheck
}
func (r *rwcMock) Close() error {
r.mutex.Lock()
defer r.mutex.Unlock()
r.closed = true
return nil
}