Files
supply-intelligence/internal/probe/state_machine_test.go
2026-05-12 18:49:52 +08:00

33 lines
1.6 KiB
Go

package probe
import (
"testing"
"supply-intelligence/internal/domain"
)
func TestNextAccountStatus(t *testing.T) {
tests := []struct {
name string
current domain.AccountStatus
consecutiveExplicitFailures int
classification domain.ProbeClassification
want domain.AccountStatus
}{
{name: "success keeps active", current: domain.AccountStatusActive, consecutiveExplicitFailures: 0, classification: domain.ProbeClassificationSuccess, want: domain.AccountStatusActive},
{name: "explicit failure active to suspended", current: domain.AccountStatusActive, consecutiveExplicitFailures: 1, classification: domain.ProbeClassificationExplicitFailure, want: domain.AccountStatusSuspended},
{name: "explicit failure suspended stays suspended before threshold", current: domain.AccountStatusSuspended, consecutiveExplicitFailures: 2, classification: domain.ProbeClassificationExplicitFailure, want: domain.AccountStatusSuspended},
{name: "explicit failure suspended to disabled at threshold", current: domain.AccountStatusSuspended, consecutiveExplicitFailures: 3, classification: domain.ProbeClassificationExplicitFailure, want: domain.AccountStatusDisabled},
{name: "inconclusive keeps active", current: domain.AccountStatusActive, consecutiveExplicitFailures: 0, classification: domain.ProbeClassificationInconclusive, want: domain.AccountStatusActive},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := NextAccountStatus(tt.current, tt.classification, tt.consecutiveExplicitFailures)
if got != tt.want {
t.Fatalf("status mismatch: got %q want %q", got, tt.want)
}
})
}
}