Commit 37ba9651 authored by watermelon's avatar watermelon

fix unit test

parent 30d62ffc
...@@ -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"
) )
......
...@@ -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(20) beforeWriteBytes.Add(10)
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(30) beforeWriteBytes.Add(10)
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)
......
...@@ -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"
) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment