Files
new-api-custom/controller/live_status_test.go
T
cneicy ceddfd3d6b feat: sync deployed v1.0.0-rc.38-custom.42
Sync production source including routing, billing, Astra detection and public uptime. Update custom build instructions and license packaging.
2026-09-26 04:49:11 +08:00

29 lines
735 B
Go

package controller
import (
"github.com/stretchr/testify/assert"
"testing"
"time"
)
func TestSuccessfulUserRequestRestoresStatus(t *testing.T) {
now := time.Now().Unix()
for _, tc := range []struct {
name string
success, probe int64
disabled bool
want int
}{
{"fresh user overrides failed probe", now, now - 10, false, 1},
{"newer failed probe wins", now - 10, now, false, 0},
{"expired success", now - 901, now - 1000, false, 0},
{"disabled remains disabled", now, now - 10, true, 0},
} {
t.Run(tc.name, func(t *testing.T) {
m := Monitor{Status: 0, ChannelDisabled: tc.disabled}
applyUserSuccess(&m, tc.success, tc.probe, now)
assert.Equal(t, tc.want, m.Status)
})
}
}