mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-07-15 09:06:07 +00:00
chore: bump deps and modernize test loops
- release.yml: download-artifact v7 -> v8 - frontend: i18next 26.3.1 -> 26.3.2, qs 6.15.2 -> 6.15.3 - go.mod: consolidate indirect requires (go mod tidy) - tests: adopt Go 1.22 range-over-int loops
This commit is contained in:
@@ -27,12 +27,12 @@ func TestStatsForClient_OrphanedInboundIdFallback(t *testing.T) {
|
||||
|
||||
db := database.GetDB()
|
||||
if err := db.Create(&xray.ClientTraffic{
|
||||
InboundId: 999,
|
||||
Email: email,
|
||||
Up: 15 * gb,
|
||||
Down: 5 * gb,
|
||||
Total: total,
|
||||
Enable: true,
|
||||
InboundId: 999,
|
||||
Email: email,
|
||||
Up: 15 * gb,
|
||||
Down: 5 * gb,
|
||||
Total: total,
|
||||
Enable: true,
|
||||
}).Error; err != nil {
|
||||
t.Fatalf("seed orphaned traffic: %v", err)
|
||||
}
|
||||
|
||||
@@ -367,7 +367,7 @@ func TestMonitorNilRecoverStaysBounded(t *testing.T) {
|
||||
|
||||
monitor := newWithClient(cfg, failingClient(), nil)
|
||||
|
||||
for i := 0; i < 5; i++ {
|
||||
for range 5 {
|
||||
recovered, _ := monitor.Step(context.Background())
|
||||
if recovered {
|
||||
t.Fatal("a nil recovery func must never report recovery")
|
||||
@@ -402,7 +402,7 @@ func TestMonitorFailuresCappedDuringCooldown(t *testing.T) {
|
||||
t.Fatal("expected recovery once the threshold is reached")
|
||||
}
|
||||
|
||||
for i := 0; i < 6; i++ {
|
||||
for range 6 {
|
||||
monitor.Step(context.Background())
|
||||
if monitor.failures > cfg.FailureThreshold {
|
||||
t.Fatalf("failures must never exceed threshold %d during cooldown, got %d", cfg.FailureThreshold, monitor.failures)
|
||||
|
||||
@@ -34,7 +34,7 @@ func TestMetricMemoryFootprint(t *testing.T) {
|
||||
|
||||
oldFlat := retained(func() any {
|
||||
m := make(map[string][]MetricSample, metrics)
|
||||
for i := 0; i < metrics; i++ {
|
||||
for i := range metrics {
|
||||
buf := make([]MetricSample, 86400)
|
||||
fill(buf)
|
||||
m[fmt.Sprintf("m%d", i)] = buf
|
||||
@@ -44,7 +44,7 @@ func TestMetricMemoryFootprint(t *testing.T) {
|
||||
|
||||
newTiered := retained(func() any {
|
||||
h := newMetricHistory()
|
||||
for i := 0; i < metrics; i++ {
|
||||
for i := range metrics {
|
||||
s := newSeries()
|
||||
for _, tb := range s.tiers {
|
||||
buf := make([]MetricSample, tb.capacity)
|
||||
@@ -83,7 +83,7 @@ func TestTierBufRollupAveragesClosedBuckets(t *testing.T) {
|
||||
|
||||
func TestTierBufRespectsCapacity(t *testing.T) {
|
||||
tb := &tierBuf{resolution: 1, capacity: 5}
|
||||
for i := int64(0); i < 20; i++ {
|
||||
for i := range int64(20) {
|
||||
tb.add(i, float64(i))
|
||||
}
|
||||
if len(tb.samples) != 5 {
|
||||
@@ -133,7 +133,7 @@ func TestAggregateFineRealtime(t *testing.T) {
|
||||
func TestAggregateLongSpanUsesCoarseTier(t *testing.T) {
|
||||
h := newMetricHistory()
|
||||
now := time.Now().Unix()
|
||||
for i := int64(0); i < 200; i++ {
|
||||
for i := range int64(200) {
|
||||
ts := now - (200-i)*600
|
||||
h.append("cpu", time.Unix(ts, 0), float64(i))
|
||||
}
|
||||
@@ -147,7 +147,7 @@ func TestAggregateLongSpanUsesCoarseTier(t *testing.T) {
|
||||
func TestSnapshotRestoreRoundTrip(t *testing.T) {
|
||||
h := newMetricHistory()
|
||||
now := time.Now().Unix()
|
||||
for i := int64(0); i < 10; i++ {
|
||||
for i := range int64(10) {
|
||||
h.append("cpu", time.Unix(now-(9-i)*2, 0), float64(i))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user