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 "context"
5 "errors"
6 "testing"
7
8 "github.com/carlosframework/platform/internal/hostbox"
9 "github.com/carlosframework/platform/internal/hostclaim"
10 "github.com/carlosframework/platform/internal/hostwrite"
11)
12
13func TestClaimServingAssemblyRequiresRetirementBeforeRuntime(t *testing.T) {
14 for _, missing := range []string{"legacy", "enrollment", "recovery"} {
15 t.Run(missing, func(t *testing.T) {
16 called := false
17 w := &ClaimWakeAssembly{RequireServingEnrollment: true,
18 BeforeLegacyInstall: func(context.Context, hostclaim.Observed, ClaimLaunchInputs, hostwrite.Work) error {
19 called = true
20 return nil
21 },
22 BeforeInstallLocked: func(context.Context, hostclaim.Observed, ClaimLaunchInputs) error { called = true; return nil },
23 RecoverArtifacts: func(context.Context, hostclaim.Observed, ClaimLaunchInputs) error { called = true; return nil },
24 }
25 switch missing {
26 case "legacy":
27 w.BeforeLegacyInstall = nil
28 case "enrollment":
29 w.BeforeInstallLocked = nil
30 case "recovery":
31 w.RecoverArtifacts = nil
32 }
33 runtime, err := w.Build(t.Context(), hostbox.WorkSource{}, hostbox.Writer{})
34 var dep *ClaimDependencyError
35 if runtime != nil || !errors.As(err, &dep) || called {
36 t.Fatalf("missing %s: runtime=%v err=%v effects=%v", missing, runtime, err, called)
37 }
38 })
39 }
40}
41