Download this file
| 1 | package console |
| 2 | |
| 3 | import ( |
| 4 | "context" |
| 5 | "errors" |
| 6 | "testing" |
| 7 | |
| 8 | "github.com/carlosframework/platform/internal/hostops" |
| 9 | "github.com/carlosframework/platform/internal/provision" |
| 10 | "github.com/carlosframework/platform/internal/release" |
| 11 | ) |
| 12 | |
| 13 | func TestClaimRecoveryAndRetirementAreInert(t *testing.T) { |
| 14 | s := &Server{cfg: Config{Releases: release.NewDirStore(t.TempDir())}} |
| 15 | ctx := context.Background() |
| 16 | if err := s.claimRecoveryPass(ctx); err != nil { |
| 17 | t.Fatal(err) |
| 18 | } |
| 19 | s.StartClaimRecoveryPass(ctx) // Must return without a ticker or store reads. |
| 20 | ref := provision.RetireRef{Family: "instance", Account: "bab", App: "jam", Host: "shop.bab.example.com"} |
| 21 | if err := s.retireHostRecord(ctx, ref); err != nil { |
| 22 | t.Fatal(err) |
| 23 | } |
| 24 | s.cfg.HostClaim = true |
| 25 | if err := s.claimRecoveryPass(ctx); !errors.Is(err, hostops.ErrContract) { |
| 26 | t.Fatal(err) |
| 27 | } |
| 28 | if err := s.retireHostRecord(ctx, ref); !errors.Is(err, provision.ErrClaimRetirer) { |
| 29 | t.Fatal(err) |
| 30 | } |
| 31 | } |
| 32 | |