mirror of
https://github.com/bjdgyc/anylink.git
synced 2025-08-11 00:31:40 +08:00
修复测试bug
This commit is contained in:
@@ -13,6 +13,7 @@ import (
|
||||
)
|
||||
|
||||
func preData(tmpDir string) {
|
||||
base.Test()
|
||||
tmpDb := path.Join(tmpDir, "test.db")
|
||||
base.Cfg.DbFile = tmpDb
|
||||
base.Cfg.Ipv4CIDR = "192.168.3.0/24"
|
||||
|
@@ -7,17 +7,17 @@ import (
|
||||
)
|
||||
|
||||
func TestNewSession(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
ast := assert.New(t)
|
||||
sessions = make(map[string]*Session)
|
||||
sess := NewSession("")
|
||||
token := sess.Token
|
||||
v, ok := sessions[token]
|
||||
assert.True(ok)
|
||||
assert.Equal(sess, v)
|
||||
ast.True(ok)
|
||||
ast.Equal(sess, v)
|
||||
}
|
||||
|
||||
func TestConnSession(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
ast := assert.New(t)
|
||||
tmp := t.TempDir()
|
||||
preData(tmp)
|
||||
defer cleardata(tmp)
|
||||
@@ -29,10 +29,10 @@ func TestConnSession(t *testing.T) {
|
||||
cSess := sess.NewConn()
|
||||
|
||||
err := cSess.RateLimit(100, true)
|
||||
assert.Nil(err)
|
||||
assert.Equal(cSess.BandwidthUp, uint32(100))
|
||||
ast.Nil(err)
|
||||
ast.Equal(cSess.BandwidthUp, uint32(100))
|
||||
err = cSess.RateLimit(200, false)
|
||||
assert.Nil(err)
|
||||
assert.Equal(cSess.BandwidthDown, uint32(200))
|
||||
ast.Nil(err)
|
||||
ast.Equal(cSess.BandwidthDown, uint32(200))
|
||||
cSess.Close()
|
||||
}
|
||||
|
Reference in New Issue
Block a user