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/hostclaim"
5 "github.com/carlosframework/platform/internal/park"
6 "github.com/carlosframework/platform/internal/provision"
7 "testing"
8)
9
10func TestPlan13HomeMovePolicy(t *testing.T) {
11 for _, home := range []string{"uk", ""} {
12 c := mpClaim(hostclaim.KindLanding, provision.LandConfigured)
13 c.Op.Intent["to"] = park.HomeRegion
14 c.Op.Intent["home_region"] = home
15 s := mpSelection(c, "restore")
16 policy, _ := mpPolicy()
17 err := policy(t.Context(), c, s, mpIdentity("restore"))
18 if err == nil {
19 t.Fatalf("home=%q: %v", home, err)
20 }
21 }
22}
23
24func TestPlan13VerifiedHomeMovePolicy(t *testing.T) {
25 c := mpClaim(hostclaim.KindLanding, provision.LandConfigured)
26 c.Op.Intent["to"], c.Op.Intent["home_region"] = park.HomeRegion, "uk"
27 s := mpSelection(c, "restore")
28 s.HomeRegion, s.FleetHomeRegion = "uk", "uk"
29 policy, _ := mpPolicy()
30 if err := policy(t.Context(), c, s, mpIdentity("restore")); err != nil {
31 t.Fatal(err)
32 }
33 s.FleetHomeRegion = "ie"
34 if err := policy(t.Context(), c, s, mpIdentity("restore")); err == nil {
35 t.Fatal("conflicting fleet home accepted")
36 }
37}
38