carlos / platform Public

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

Plain git — no account needed to clone.

Download

Download this file

1package hostclaim
2
3import "testing"
4
5func TestIsOrphan(t *testing.T) {
6 if IsOrphan("A", Observed{Absent: true}) {
7 t.Fatal("no claim = legacy, never orphan")
8 }
9 held := Observed{Claim: &Claim{Holder: &Holder{Incarnation: "A"}, Op: Op{Kind: KindServing}}}
10 if IsOrphan("A", held) {
11 t.Fatal("the holder's own record is not an orphan")
12 }
13 creating := Observed{Claim: &Claim{Holder: &Holder{Incarnation: "A"}, Op: Op{Kind: KindCreating, ID: "c"}}}
14 if IsOrphan("A", creating) {
15 t.Fatal("a record of the creating incarnation is not an orphan")
16 }
17 if !IsOrphan("A", Observed{Claim: &Claim{Holder: &Holder{Incarnation: "B"}, Op: Op{Kind: KindServing}}}) {
18 t.Fatal("another incarnation's claim makes A an orphan")
19 }
20 if !IsOrphan("A", Observed{Claim: &Claim{}}) {
21 t.Fatal("a free claim makes A an orphan")
22 }
23}
24