Sync production source including routing, billing, Astra detection and public uptime. Update custom build instructions and license packaging.
29 lines
735 B
Go
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)
|
|
})
|
|
}
|
|
}
|