Download this file
| 1 | package hostclaim |
| 2 | |
| 3 | import ( |
| 4 | "strconv" |
| 5 | "testing" |
| 6 | ) |
| 7 | |
| 8 | func TestPlan12TargetReleasedCapturesWriter(t *testing.T) { |
| 9 | for _, admitted := range []bool{false, true} { |
| 10 | c := lostTargetClaim(t, KindRestoring, PhaseReleasing) |
| 11 | c.Lost, c.LossRefs, c.LostRevisions = nil, nil, nil |
| 12 | delete(c.Op.Journal, "loss."+lostID) |
| 13 | c.Op.Participants = []string{"ie-box", "uk-box"} |
| 14 | c.Op.Exec = "uk-box" |
| 15 | if !admitted { |
| 16 | c.Holder.WriterBox = "ie-box" |
| 17 | } |
| 18 | r := lostRelease(c, false) |
| 19 | if err := TargetReleased(lostOp, "uk-box", "uk", "evidence", r.Location, r.NewID)(c); err != nil { |
| 20 | t.Fatal(err) |
| 21 | } |
| 22 | if admitted { |
| 23 | if c.Op.Journal[JournalTargetSession] != strconv.FormatUint(c.Holder.Session, 10) || c.Op.Journal[JournalTargetGeneration] != c.Holder.Generation { |
| 24 | t.Fatal(c.Op.Journal) |
| 25 | } |
| 26 | } else if _, ok := c.Op.Journal[JournalTargetSession]; ok { |
| 27 | t.Fatal("invented target session") |
| 28 | } |
| 29 | } |
| 30 | } |
| 31 | |