Skip to content

Commit 7e23eaf

Browse files
committed
chore: Move errors to variables in the stream tests
1 parent ff1cbff commit 7e23eaf

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

internal/jsonrpc2/stream_test.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ import (
66
"testing"
77
)
88

9+
var errWriteContentLen = errors.New("write content length error")
10+
var errWriteMsg = errors.New("write message error")
11+
912
func TestStream(t *testing.T) {
1013
t.Parallel()
1114

@@ -102,14 +105,14 @@ type writerError struct{}
102105

103106
func (e *writerError) Write(p []byte) (n int, err error) {
104107
if strings.Contains(string(p), "Content-Length: 0") {
105-
return 0, errors.New("write content length error")
108+
return 0, errWriteContentLen
106109
}
107110

108111
if strings.Contains(string(p), "Content-Length: ") {
109112
return len(p), nil
110113
}
111114

112-
return 0, errors.New("write message error")
115+
return 0, errWriteMsg
113116
}
114117

115118
func TestStreamWriteMessageErr(t *testing.T) {

0 commit comments

Comments
 (0)