carlos / platform Public

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

Plain git — no account needed to clone.

Download

Download this file

1package host
2
3import (
4 "github.com/carlosframework/platform/internal/hostguard"
5 "testing"
6)
7
8func TestClaimContainmentNamesBindSessionAndController(t *testing.T) {
9 target := hostguard.FenceTarget{Host: "app.example", Incarnation: "inc", Stamp: 11, Session: 13, Box: "box", Enrollment: "enrollment", BootID: "boot", ControllerID: "controller"}
10 first := claimContainmentName(target)
11 bookkeeping := target
12 bookkeeping.ClaimETag = "new"
13 bookkeeping.Op = "another-op"
14 if claimContainmentName(bookkeeping) != first {
15 t.Fatal("bookkeeping changed containment")
16 }
17 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++ }} {
18 next := target
19 change(&next)
20 if claimContainmentName(next) == first {
21 t.Fatal("successor reused containment")
22 }
23 }
24}
25