Download this file
| 1 | package hostclaim |
| 2 | |
| 3 | import ( |
| 4 | "errors" |
| 5 | "testing" |
| 6 | ) |
| 7 | |
| 8 | // m-2 (platform-1e; moves Plan 3 Task 7): the commit follows probed only, so |
| 9 | // Group D's adjacent-step rule (probing, probed, committed) holds. A commit |
| 10 | // from probing is refused and leaves the claim as it found it. |
| 11 | func TestCommitAcceptsOnlyProbed(t *testing.T) { |
| 12 | c := probedLanding(t) |
| 13 | c.Op.Phase = "probing" |
| 14 | before := string(mustJSON(t, c)) |
| 15 | src, stg := commitScopes(c) |
| 16 | if err := Commit(moveA, "ie", "ie-box", "uk", src, stg, counter())(c); !errors.Is(err, ErrWrongState) || string(mustJSON(t, c)) != before { |
| 17 | t.Fatalf("a commit from probing: %v", err) |
| 18 | } |
| 19 | c = probedLanding(t) |
| 20 | c.Op.Phase = "probed" |
| 21 | src, stg = commitScopes(c) |
| 22 | if err := KeepWriterSession(moveA, Commit(moveA, "ie", "ie-box", "uk", src, stg, counter()))(c); err != nil || c.Op.Phase != PhaseCommitted { |
| 23 | t.Fatalf("a commit from probed under the session guard: %v %+v", err, c.Op) |
| 24 | } |
| 25 | } |
| 26 | |