mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-22 16:28:30 +02:00
fix two tests
This commit is contained in:
@@ -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))
|
||||||
|
|||||||
@@ -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)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user