carlos / platform Public

Clone
git clone https://amadan.net/carlos/platform

Plain git — no account needed to clone.

Download

Download this file

1package provision
2
3import (
4 "errors"
5 "testing"
6 "time"
7)
8
9// H10 (moves Plan 3 Task 6): the admission records the probe attempts its
10// T11 pricing admitted, and an absent count is the landing's recorded
11// refusal of the probe.
12func TestMoveAdmitRecordsTheProbeAttempts(t *testing.T) {
13 g := cutTestGuard()
14 now := time.Date(2026, 10, 9, 9, 0, 0, 0, time.UTC)
15 cutting := func() *Record {
16 return &Record{Region: "ie", Move: &MoveState{ID: g.ID, Incarnation: g.Incarnation, From: "ie", To: "uk", State: MoveCutting, CutPhase: CutRequested, Inputs: &MoveInputs{Release: "v1"}}}
17 }
18 rec := cutting()
19 if err := MoveAdmit(g, now, 120, now.Add(time.Minute), 2)(rec); err != nil || rec.Move.CutAttempts != 2 {
20 t.Fatalf("admit: %v %+v", err, rec.Move)
21 }
22 rec = cutting()
23 if err := MoveAdmit(g, now, 120, now.Add(time.Minute), -1)(rec); !errors.Is(err, ErrMoveConflict) || rec.Move.CutPhase != CutRequested || rec.Move.CutAttempts != 0 {
24 t.Fatalf("a negative count: %v %+v", err, rec.Move)
25 }
26 landing := &Record{Region: "uk", Move: &MoveState{ID: g.ID, Incarnation: g.Incarnation, From: "ie", To: "uk", State: MoveLanding, LandingPhase: LandProbing}}
27 if err := MoveMarkRollback(g, RollbackProbeUnpriced)(landing); err != nil || landing.Move.Reason != RollbackProbeUnpriced {
28 t.Fatalf("the unpriced probe's mark: %v %+v", err, landing.Move)
29 }
30}
31