blob: 46bedeba1965098e1c2449b7e7a3bf4d726e57fa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
package billing
import (
"testing"
"time"
)
func TestOperationalStatusReadiness(t *testing.T) {
now := time.Now().UTC()
recent := now.Add(-time.Minute)
clean := OperationalStatus{
StripeEnabled: true, ReconciliationStatus: "clean", ReconciliationCompletedAt: &recent,
}
if !clean.Ready(now) {
t.Fatal("clean operational state should be ready")
}
oldWebhook := now.Add(-6 * time.Minute)
stuckWebhook := clean
stuckWebhook.UnprocessedWebhooks = 1
stuckWebhook.OldestUnprocessedWebhook = &oldWebhook
if stuckWebhook.Ready(now) {
t.Fatal("stuck webhook should fail readiness")
}
freshRefund := now.Add(-time.Minute)
processingRefund := clean
processingRefund.RefundBacklog = 1
processingRefund.OldestRefund = &freshRefund
if !processingRefund.Ready(now) {
t.Fatal("fresh refund operation should remain ready during its processing window")
}
unmetered := clean
unmetered.UnmeteredSuccesses = 1
if unmetered.Ready(now) {
t.Fatal("unmetered success must fail readiness")
}
}
|