agent v0.85.0 WIP: F12/F11/F10/F9/F2/F1 boot-recovery plane + appliance self-heal (pre-build)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017CDMFpFx84pfviCTVuGGhf
This commit is contained in:
@@ -133,3 +133,41 @@ func TestLoadFileThenEnvOverride(t *testing.T) {
|
||||
t.Errorf("default endpoint lost: %q", cfg.Proxmox.Endpoint)
|
||||
}
|
||||
}
|
||||
|
||||
// CAMPAIGN-3 Part 6: deployment_mode gates node self-heal, and it is FAIL-SAFE to byo — absent or any
|
||||
// unknown value is byo, ONLY the exact "appliance" unlocks the remedy.
|
||||
func TestIsAppliance_FailSafeToByo(t *testing.T) {
|
||||
cases := []struct {
|
||||
mode string
|
||||
want bool
|
||||
}{
|
||||
{"appliance", true},
|
||||
{"byo", false},
|
||||
{"", false}, // absent field → byo (fail-safe)
|
||||
{"Appliance", false}, // case-sensitive — a typo must not unlock the remedy
|
||||
{"garbage", false},
|
||||
}
|
||||
for _, c := range cases {
|
||||
cfg := &Config{DeploymentMode: c.mode}
|
||||
if got := cfg.IsAppliance(); got != c.want {
|
||||
t.Errorf("IsAppliance(mode=%q) = %t, want %t", c.mode, got, c.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The env overlay can set deployment_mode (FELHOM_AGENT_DEPLOYMENT_MODE).
|
||||
func TestDeploymentModeEnvOverlay(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
path := filepath.Join(dir, "agent.json")
|
||||
if err := os.WriteFile(path, []byte(`{"proxmox":{"node":"n","token":"u@pve!t=s"},"deployment_mode":"byo"}`), 0o600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Setenv("FELHOM_AGENT_DEPLOYMENT_MODE", "appliance")
|
||||
cfg, err := Load(path)
|
||||
if err != nil {
|
||||
t.Fatalf("Load: %v", err)
|
||||
}
|
||||
if !cfg.IsAppliance() {
|
||||
t.Errorf("env overlay did not set deployment_mode: %q", cfg.DeploymentMode)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user