lolly/internal/loadbalance/slow_start_test.go
xfy 2734b04d8f refactor: remove 16.8k lines of dead code across all internal packages
- Delete unused files: tempfile subsystem, matcher variants, server/internal
- Remove 200+ unused functions across proxy, ssl, lua, http2/3, stream, variable
- Fix proxy test type errors (backgroundRefresh ctx→Request)
- Move bench/tools mock backend into internal/testutil
- Remove corresponding test functions for all deleted code
2026-06-03 16:15:43 +08:00

48 lines
884 B
Go

package loadbalance
import "testing"
func TestTarget_GetEffectiveWeight(t *testing.T) {
tests := []struct {
name string
weight int
effectiveWeight int64
want int
}{
{
name: "no slow start",
weight: 10,
effectiveWeight: 0,
want: 10,
},
{
name: "slow start in progress",
weight: 10,
effectiveWeight: 5,
want: 5,
},
{
name: "slow start at 1",
weight: 10,
effectiveWeight: 1,
want: 1,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
target := &Target{
Weight: tt.weight,
}
target.EffectiveWeight.Store(tt.effectiveWeight)
got := target.GetEffectiveWeight()
if got != tt.want {
t.Errorf("GetEffectiveWeight() = %d, want %d", got, tt.want)
}
})
}
}