Commit 37ba9651 authored by watermelon's avatar watermelon

fix unit test

parent 30d62ffc
......@@ -35,7 +35,6 @@ import (
"github.com/dubbogo/gost/net"
gxsync "github.com/dubbogo/gost/sync"
gxtime "github.com/dubbogo/gost/time"
"github.com/gorilla/websocket"
perrors "github.com/pkg/errors"
)
......
......@@ -146,8 +146,8 @@ func TestTCPClient(t *testing.T) {
l, err = ss.WriteBytes([]byte("hello"))
assert.Nil(t, err)
assert.True(t, l == 5)
beforeWriteBytes.Add(10)
beforeWritePkgNum.Add(2)
beforeWriteBytes.Add(5)
beforeWritePkgNum.Add(1)
assert.Equal(t, beforeWriteBytes, conn.writeBytes)
assert.Equal(t, beforeWritePkgNum, conn.writePkgNum)
var pkgs [][]byte
......@@ -155,16 +155,16 @@ func TestTCPClient(t *testing.T) {
l, err = conn.send(pkgs)
assert.Nil(t, err)
assert.True(t, l == 10)
beforeWritePkgNum.Add(4)
beforeWriteBytes.Add(20)
beforeWritePkgNum.Add(2)
beforeWriteBytes.Add(10)
assert.Equal(t, beforeWritePkgNum, conn.writePkgNum)
assert.Equal(t, beforeWriteBytes, conn.writeBytes)
ss.SetCompressType(CompressSnappy)
l, err = ss.WriteBytesArray(pkgs...)
assert.Nil(t, err)
assert.True(t, l == 10)
beforeWritePkgNum.Add(6)
beforeWriteBytes.Add(30)
beforeWritePkgNum.Add(2)
beforeWriteBytes.Add(10)
assert.Equal(t, beforeWritePkgNum, conn.writePkgNum)
assert.Equal(t, beforeWriteBytes, conn.writeBytes)
assert.True(t, conn.compress == CompressSnappy)
......@@ -324,7 +324,7 @@ func TestNewWSClient(t *testing.T) {
l, err = ss.WriteBytesArray([]byte("hello"), []byte("hello"))
assert.Nil(t, err)
assert.True(t, l == 10)
beforeWritePkgNum.Add(3)
beforeWritePkgNum.Add(2)
assert.Equal(t, beforeWritePkgNum, conn.writePkgNum)
err = conn.writePing()
assert.Nil(t, err)
......
......@@ -30,7 +30,6 @@ import (
import (
"github.com/golang/snappy"
"github.com/gorilla/websocket"
perrors "github.com/pkg/errors"
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