Clarify run-if skip reasons with the resolved variable value.

Failed conditions now explain skips in plain language (e.g. UpdateCount was 0) and truncate long captures so misconfigured apt listings cannot flood the UI.
This commit is contained in:
2026-07-19 21:59:35 +02:00
parent eade2ef0c7
commit 0e06063c1d
8 changed files with 865 additions and 46 deletions
+33
View File
@@ -0,0 +1,33 @@
package runner
import "testing"
func TestValidateVariableName(t *testing.T) {
if err := ValidateVariableName("UpdateCount"); err != nil {
t.Fatalf("UpdateCount: %v", err)
}
if err := ValidateVariableName("_x"); err != nil {
t.Fatalf("_x: %v", err)
}
if err := ValidateVariableName(""); err == nil {
t.Fatal("expected empty name error")
}
if err := ValidateVariableName("1bad"); err == nil {
t.Fatal("expected invalid name error")
}
if err := ValidateVariableName("bad-name"); err == nil {
t.Fatal("expected invalid name error")
}
}
func TestExpandDollarVars(t *testing.T) {
vars := map[string]string{"UpdateCount": "3", "Name": "web"}
got := ExpandDollarVars("count=$UpdateCount host=${Name}-01 keep=$HOME", vars)
want := "count=3 host=web-01 keep=$HOME"
if got != want {
t.Fatalf("got %q want %q", got, want)
}
if ExpandDollarVars("$Missing", nil) != "$Missing" {
t.Fatal("nil vars should leave tokens unchanged")
}
}