Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
G
getty
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wei.xuan
getty
Commits
37ba9651
Commit
37ba9651
authored
Feb 28, 2021
by
watermelon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix unit test
parent
30d62ffc
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
9 deletions
+7
-9
client.go
client.go
+0
-1
client_test.go
client_test.go
+7
-7
connection.go
connection.go
+0
-1
No files found.
client.go
View file @
37ba9651
...
@@ -35,7 +35,6 @@ import (
...
@@ -35,7 +35,6 @@ import (
"github.com/dubbogo/gost/net"
"github.com/dubbogo/gost/net"
gxsync
"github.com/dubbogo/gost/sync"
gxsync
"github.com/dubbogo/gost/sync"
gxtime
"github.com/dubbogo/gost/time"
gxtime
"github.com/dubbogo/gost/time"
"github.com/gorilla/websocket"
"github.com/gorilla/websocket"
perrors
"github.com/pkg/errors"
perrors
"github.com/pkg/errors"
)
)
...
...
client_test.go
View file @
37ba9651
...
@@ -146,8 +146,8 @@ func TestTCPClient(t *testing.T) {
...
@@ -146,8 +146,8 @@ func TestTCPClient(t *testing.T) {
l
,
err
=
ss
.
WriteBytes
([]
byte
(
"hello"
))
l
,
err
=
ss
.
WriteBytes
([]
byte
(
"hello"
))
assert
.
Nil
(
t
,
err
)
assert
.
Nil
(
t
,
err
)
assert
.
True
(
t
,
l
==
5
)
assert
.
True
(
t
,
l
==
5
)
beforeWriteBytes
.
Add
(
10
)
beforeWriteBytes
.
Add
(
5
)
beforeWritePkgNum
.
Add
(
2
)
beforeWritePkgNum
.
Add
(
1
)
assert
.
Equal
(
t
,
beforeWriteBytes
,
conn
.
writeBytes
)
assert
.
Equal
(
t
,
beforeWriteBytes
,
conn
.
writeBytes
)
assert
.
Equal
(
t
,
beforeWritePkgNum
,
conn
.
writePkgNum
)
assert
.
Equal
(
t
,
beforeWritePkgNum
,
conn
.
writePkgNum
)
var
pkgs
[][]
byte
var
pkgs
[][]
byte
...
@@ -155,16 +155,16 @@ func TestTCPClient(t *testing.T) {
...
@@ -155,16 +155,16 @@ func TestTCPClient(t *testing.T) {
l
,
err
=
conn
.
send
(
pkgs
)
l
,
err
=
conn
.
send
(
pkgs
)
assert
.
Nil
(
t
,
err
)
assert
.
Nil
(
t
,
err
)
assert
.
True
(
t
,
l
==
10
)
assert
.
True
(
t
,
l
==
10
)
beforeWritePkgNum
.
Add
(
4
)
beforeWritePkgNum
.
Add
(
2
)
beforeWriteBytes
.
Add
(
2
0
)
beforeWriteBytes
.
Add
(
1
0
)
assert
.
Equal
(
t
,
beforeWritePkgNum
,
conn
.
writePkgNum
)
assert
.
Equal
(
t
,
beforeWritePkgNum
,
conn
.
writePkgNum
)
assert
.
Equal
(
t
,
beforeWriteBytes
,
conn
.
writeBytes
)
assert
.
Equal
(
t
,
beforeWriteBytes
,
conn
.
writeBytes
)
ss
.
SetCompressType
(
CompressSnappy
)
ss
.
SetCompressType
(
CompressSnappy
)
l
,
err
=
ss
.
WriteBytesArray
(
pkgs
...
)
l
,
err
=
ss
.
WriteBytesArray
(
pkgs
...
)
assert
.
Nil
(
t
,
err
)
assert
.
Nil
(
t
,
err
)
assert
.
True
(
t
,
l
==
10
)
assert
.
True
(
t
,
l
==
10
)
beforeWritePkgNum
.
Add
(
6
)
beforeWritePkgNum
.
Add
(
2
)
beforeWriteBytes
.
Add
(
3
0
)
beforeWriteBytes
.
Add
(
1
0
)
assert
.
Equal
(
t
,
beforeWritePkgNum
,
conn
.
writePkgNum
)
assert
.
Equal
(
t
,
beforeWritePkgNum
,
conn
.
writePkgNum
)
assert
.
Equal
(
t
,
beforeWriteBytes
,
conn
.
writeBytes
)
assert
.
Equal
(
t
,
beforeWriteBytes
,
conn
.
writeBytes
)
assert
.
True
(
t
,
conn
.
compress
==
CompressSnappy
)
assert
.
True
(
t
,
conn
.
compress
==
CompressSnappy
)
...
@@ -324,7 +324,7 @@ func TestNewWSClient(t *testing.T) {
...
@@ -324,7 +324,7 @@ func TestNewWSClient(t *testing.T) {
l
,
err
=
ss
.
WriteBytesArray
([]
byte
(
"hello"
),
[]
byte
(
"hello"
))
l
,
err
=
ss
.
WriteBytesArray
([]
byte
(
"hello"
),
[]
byte
(
"hello"
))
assert
.
Nil
(
t
,
err
)
assert
.
Nil
(
t
,
err
)
assert
.
True
(
t
,
l
==
10
)
assert
.
True
(
t
,
l
==
10
)
beforeWritePkgNum
.
Add
(
3
)
beforeWritePkgNum
.
Add
(
2
)
assert
.
Equal
(
t
,
beforeWritePkgNum
,
conn
.
writePkgNum
)
assert
.
Equal
(
t
,
beforeWritePkgNum
,
conn
.
writePkgNum
)
err
=
conn
.
writePing
()
err
=
conn
.
writePing
()
assert
.
Nil
(
t
,
err
)
assert
.
Nil
(
t
,
err
)
...
...
connection.go
View file @
37ba9651
...
@@ -30,7 +30,6 @@ import (
...
@@ -30,7 +30,6 @@ import (
import
(
import
(
"github.com/golang/snappy"
"github.com/golang/snappy"
"github.com/gorilla/websocket"
"github.com/gorilla/websocket"
perrors
"github.com/pkg/errors"
perrors
"github.com/pkg/errors"
uatomic
"go.uber.org/atomic"
uatomic
"go.uber.org/atomic"
)
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment