forked from ipfs/go-ipfs-cmds
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelpers_test.go
43 lines (34 loc) · 896 Bytes
/
helpers_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package cmds
import (
"io"
"testing"
)
// nopClose implements io.Close and does nothing
type nopCloser struct{}
func (c nopCloser) Close() error { return nil }
type testEmitter testing.T
func (s *testEmitter) Close() error {
return nil
}
func (s *testEmitter) SetLength(_ uint64) {}
func (s *testEmitter) CloseWithError(err error) error {
if err != nil {
(*testing.T)(s).Error(err)
}
return nil
}
func (s *testEmitter) Emit(value interface{}) error {
return nil
}
// newTestEmitter fails the test if it receives an error.
func newTestEmitter(t *testing.T) *testEmitter {
return (*testEmitter)(t)
}
// noop does nothing and can be used as a noop Run function
func noop(req *Request, re ResponseEmitter, env Environment) error { return nil }
// writecloser implements io.WriteCloser by embedding
// an io.Writer and an io.Closer
type writecloser struct {
io.Writer
io.Closer
}