carlos / platform Public

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

Plain git — no account needed to clone.

Download

Download this file

1package hostops
2
3import (
4 "context"
5 "github.com/carlosframework/platform/internal/hostclaim"
6 "github.com/carlosframework/platform/internal/termfence"
7 "testing"
8)
9
10type plan13BoundFence struct{ home, region string }
11
12func (a plan13BoundFence) ValidateFence(context.Context, termfence.Record) (hostclaim.FenceBinding, error) {
13 return hostclaim.FenceBinding{FleetHomeRegion: a.home, Region: a.region, RosterRevision: 1, RosterETag: "signed"}, nil
14}
15func TestPlan13FenceRequiresSignedHome(t *testing.T) {
16 for _, home := range []string{"ie", "ca", ""} {
17 a := MoveFenceRegions{Authority: plan13BoundFence{home: "ie", region: "ca"}, HomeRegion: home}
18 got, err := a.ValidateFence(t.Context(), termfence.Record{})
19 if home == "ca" {
20 if err == nil {
21 t.Fatal("named fence projected to home", got)
22 }
23 continue
24 }
25 if err != nil || got.Region != "ca" {
26 t.Fatal(got, err)
27 }
28 }
29}
30