hub: configgen test pinning logging.level=debug propagation (v0.42.0 e2e leg)

Proves a customer ConfigJSON logging.level=debug deep-merges over the template
default into the generated controller.yaml — the integration leg the remote
debug-mode toggle depends on. Merge target (logging.level: info) verified live
on the demo controller.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PSK5g6qYLknKj8u3QAFEr6
This commit is contained in:
2026-07-10 15:21:55 +02:00
parent 0f28add0bf
commit 9f1759132d
@@ -0,0 +1,40 @@
package configgen
import (
"strings"
"testing"
"gitea.dooplex.hu/admin/felhom-hub/internal/store"
)
// The remote debug-mode toggle (hub v0.42.0) relies on this integration: a customer ConfigJSON carrying
// logging.level=debug must deep-merge OVER the template default into the generated controller.yaml, so the
// controller's isDebug() (Logging.Level=="debug") lights up the /debug menu + verbose log. Verified live on
// the demo box (2026-07-10): its controller.yaml carries `logging.level: info` — the exact merge target this
// pins. Without this leg the hub toggle would be a silent no-op.
func TestGenerate_DebugLevelOverride(t *testing.T) {
const tmpl = "logging:\n level: info\n"
// Override present → the generated YAML carries level: debug, and the info default is gone.
dbg, err := Generate(tmpl, &store.CustomerConfig{
CustomerID: "c1", ConfigJSON: `{"logging":{"level":"debug"}}`,
})
if err != nil {
t.Fatalf("generate (debug): %v", err)
}
if !strings.Contains(dbg, "level: debug") {
t.Fatalf("logging.level=debug override did not reach controller.yaml:\n%s", dbg)
}
if strings.Contains(dbg, "level: info") {
t.Fatalf("the info default should have been overridden by debug:\n%s", dbg)
}
// No override → the template default (info) stands, debug absent.
def, err := Generate(tmpl, &store.CustomerConfig{CustomerID: "c1", ConfigJSON: "{}"})
if err != nil {
t.Fatalf("generate (default): %v", err)
}
if !strings.Contains(def, "level: info") || strings.Contains(def, "level: debug") {
t.Fatalf("no override should leave level: info intact:\n%s", def)
}
}