package host import ( "github.com/carlosframework/platform/internal/hostguard" "testing" ) func TestClaimContainmentNamesBindSessionAndController(t *testing.T) { target := hostguard.FenceTarget{Host: "app.example", Incarnation: "inc", Stamp: 11, Session: 13, Box: "box", Enrollment: "enrollment", BootID: "boot", ControllerID: "controller"} first := claimContainmentName(target) bookkeeping := target bookkeeping.ClaimETag = "new" bookkeeping.Op = "another-op" if claimContainmentName(bookkeeping) != first { t.Fatal("bookkeeping changed containment") } for _, change := range []func(*hostguard.FenceTarget){func(t *hostguard.FenceTarget) { t.Session++ }, func(t *hostguard.FenceTarget) { t.ControllerID = "other" }, func(t *hostguard.FenceTarget) { t.BootID = "new-boot" }, func(t *hostguard.FenceTarget) { t.Stamp++ }} { next := target change(&next) if claimContainmentName(next) == first { t.Fatal("successor reused containment") } } }