fix two tests

This commit is contained in:
yusing 2025-02-01 14:41:22 +08:00
parent 78900772bb
commit 43fce6e739
2 changed files with 4 additions and 5 deletions

View file

@ -4,14 +4,13 @@ import (
"testing" "testing"
"github.com/yusing/go-proxy/internal/net/http/loadbalancer/types" "github.com/yusing/go-proxy/internal/net/http/loadbalancer/types"
loadbalance "github.com/yusing/go-proxy/internal/net/http/loadbalancer/types"
. "github.com/yusing/go-proxy/internal/utils/testing" . "github.com/yusing/go-proxy/internal/utils/testing"
) )
func TestRebalance(t *testing.T) { func TestRebalance(t *testing.T) {
t.Parallel() t.Parallel()
t.Run("zero", func(t *testing.T) { t.Run("zero", func(t *testing.T) {
lb := New(new(loadbalance.Config)) lb := New(new(types.Config))
for range 10 { for range 10 {
lb.AddServer(types.TestNewServer(0)) lb.AddServer(types.TestNewServer(0))
} }
@ -19,7 +18,7 @@ func TestRebalance(t *testing.T) {
ExpectEqual(t, lb.sumWeight, maxWeight) ExpectEqual(t, lb.sumWeight, maxWeight)
}) })
t.Run("less", func(t *testing.T) { t.Run("less", func(t *testing.T) {
lb := New(new(loadbalance.Config)) lb := New(new(types.Config))
lb.AddServer(types.TestNewServer(float64(maxWeight) * .1)) lb.AddServer(types.TestNewServer(float64(maxWeight) * .1))
lb.AddServer(types.TestNewServer(float64(maxWeight) * .2)) lb.AddServer(types.TestNewServer(float64(maxWeight) * .2))
lb.AddServer(types.TestNewServer(float64(maxWeight) * .3)) lb.AddServer(types.TestNewServer(float64(maxWeight) * .3))
@ -30,7 +29,7 @@ func TestRebalance(t *testing.T) {
ExpectEqual(t, lb.sumWeight, maxWeight) ExpectEqual(t, lb.sumWeight, maxWeight)
}) })
t.Run("more", func(t *testing.T) { t.Run("more", func(t *testing.T) {
lb := New(new(loadbalance.Config)) lb := New(new(types.Config))
lb.AddServer(types.TestNewServer(float64(maxWeight) * .1)) lb.AddServer(types.TestNewServer(float64(maxWeight) * .1))
lb.AddServer(types.TestNewServer(float64(maxWeight) * .2)) lb.AddServer(types.TestNewServer(float64(maxWeight) * .2))
lb.AddServer(types.TestNewServer(float64(maxWeight) * .3)) lb.AddServer(types.TestNewServer(float64(maxWeight) * .3))

View file

@ -41,7 +41,7 @@ func TestHTTPConfigDeserialize(t *testing.T) {
if err != nil { if err != nil {
ExpectNoError(t, err) ExpectNoError(t, err)
} }
ExpectDeepEqual(t, cfg.HTTPConfig, &tt.expected) ExpectDeepEqual(t, cfg.HTTPConfig, tt.expected)
}) })
} }
} }