chore: cleanup test code

This commit is contained in:
Dreamacro
2022-05-21 17:37:06 +08:00
committed by 世界
parent b9e6de45e6
commit 7079116aa8
10 changed files with 161 additions and 242 deletions

View File

@@ -8,7 +8,7 @@ import (
"github.com/Dreamacro/clash/adapter/outbound"
C "github.com/Dreamacro/clash/constant"
"github.com/docker/docker/api/types/container"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestClash_SnellObfsHTTP(t *testing.T) {
@@ -23,9 +23,7 @@ func TestClash_SnellObfsHTTP(t *testing.T) {
}
id, err := startContainer(cfg, hostCfg, "snell-http")
if err != nil {
assert.FailNow(t, err.Error())
}
require.NoError(t, err)
t.Cleanup(func() {
cleanContainer(id)
@@ -40,9 +38,7 @@ func TestClash_SnellObfsHTTP(t *testing.T) {
"mode": "http",
},
})
if err != nil {
assert.FailNow(t, err.Error())
}
require.NoError(t, err)
time.Sleep(waitTime)
testSuit(t, proxy)
@@ -60,9 +56,7 @@ func TestClash_SnellObfsTLS(t *testing.T) {
}
id, err := startContainer(cfg, hostCfg, "snell-tls")
if err != nil {
assert.FailNow(t, err.Error())
}
require.NoError(t, err)
t.Cleanup(func() {
cleanContainer(id)
@@ -77,9 +71,7 @@ func TestClash_SnellObfsTLS(t *testing.T) {
"mode": "tls",
},
})
if err != nil {
assert.FailNow(t, err.Error())
}
require.NoError(t, err)
time.Sleep(waitTime)
testSuit(t, proxy)
@@ -97,9 +89,7 @@ func TestClash_Snell(t *testing.T) {
}
id, err := startContainer(cfg, hostCfg, "snell")
if err != nil {
assert.FailNow(t, err.Error())
}
require.NoError(t, err)
t.Cleanup(func() {
cleanContainer(id)
@@ -111,9 +101,7 @@ func TestClash_Snell(t *testing.T) {
Port: 10002,
Psk: "password",
})
if err != nil {
assert.FailNow(t, err.Error())
}
require.NoError(t, err)
time.Sleep(waitTime)
testSuit(t, proxy)
@@ -131,9 +119,7 @@ func TestClash_Snellv3(t *testing.T) {
}
id, err := startContainer(cfg, hostCfg, "snell")
if err != nil {
assert.FailNow(t, err.Error())
}
require.NoError(t, err)
t.Cleanup(func() {
cleanContainer(id)
@@ -147,9 +133,7 @@ func TestClash_Snellv3(t *testing.T) {
UDP: true,
Version: 3,
})
if err != nil {
assert.FailNow(t, err.Error())
}
require.NoError(t, err)
time.Sleep(waitTime)
testSuit(t, proxy)
@@ -167,9 +151,7 @@ func Benchmark_Snell(b *testing.B) {
}
id, err := startContainer(cfg, hostCfg, "snell-http")
if err != nil {
assert.FailNow(b, err.Error())
}
require.NoError(b, err)
b.Cleanup(func() {
cleanContainer(id)
@@ -184,9 +166,7 @@ func Benchmark_Snell(b *testing.B) {
"mode": "http",
},
})
if err != nil {
assert.FailNow(b, err.Error())
}
require.NoError(b, err)
time.Sleep(waitTime)
benchmarkProxy(b, proxy)