hub v0.28.0 + host-install v1.2.0: settings→Configuration, online install, vmid auto-detect
Part A (hub): move the global-floor + Day-0-artifacts cards from the Customers
page to the Configuration tab; routes → /configuration/{global-floor,artifacts};
redirects + flashes to /configuration. Customers page back to list + Add.
Part B: online setup command on the customer page (download-then-run, passphrase
at prompt, not templated); serve /scripts/ from the website (sparse-checkout +
nginx location) so felhom.eu/scripts/felhom-host-install.sh resolves; script
passphrase prompt reads < /dev/tty (works for pipe-to-bash too).
Part C (script): --vmid auto-detect — default 9201 in use + no --force → pick the
next free id from pct+qm and confirm; explicit --vmid stays die-unless-force.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -4,15 +4,17 @@ import (
|
||||
"bytes"
|
||||
"io"
|
||||
"log"
|
||||
"net/http/httptest"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"gitea.dooplex.hu/admin/felhom-hub/internal/store"
|
||||
)
|
||||
|
||||
// Catches template SYNTAX errors (template.Must in New panics) and that the floor fields render on the
|
||||
// two edited pages. Field-level execution errors surface as a non-nil ExecuteTemplate error.
|
||||
// Catches template SYNTAX errors (template.Must in New panics) and that the per-customer floor renders
|
||||
// on the Customers list. Field-level execution errors surface as a non-nil ExecuteTemplate error.
|
||||
func TestTemplates_FloorRender(t *testing.T) {
|
||||
st, err := store.New(filepath.Join(t.TempDir(), "t.db"), log.New(io.Discard, "", 0))
|
||||
if err != nil {
|
||||
@@ -21,29 +23,50 @@ func TestTemplates_FloorRender(t *testing.T) {
|
||||
t.Cleanup(func() { st.Close() })
|
||||
s := New(st, "", "", "test", time.Hour, log.New(io.Discard, "", 0)) // template.Must runs here
|
||||
|
||||
// configs.html — the list page data shape used by handleConfigList.
|
||||
// configs.html — the list page data shape used by handleConfigList (global floor/artifacts moved
|
||||
// to the Configuration tab; the per-customer effective floor still renders here).
|
||||
cfgData := struct {
|
||||
Customers []customerListEntry
|
||||
GlobalFloor string
|
||||
Artifacts store.ArtifactManifest
|
||||
ActiveNav string
|
||||
Flash string
|
||||
CSRFToken string
|
||||
CSRFField string
|
||||
Customers []customerListEntry
|
||||
ActiveNav string
|
||||
Flash string
|
||||
}{
|
||||
Customers: []customerListEntry{{
|
||||
CustomerID: "c", EffectiveFloor: "0.87.0", FloorOverride: "0.87.0", BelowFloor: true,
|
||||
ControllerVersion: "0.86.0", HasConfig: true,
|
||||
}},
|
||||
GlobalFloor: "0.86.0",
|
||||
Artifacts: store.ArtifactManifest{AgentVersion: "0.43.0", GoldenVersion: "0.85.1"},
|
||||
ActiveNav: "configs",
|
||||
ActiveNav: "configs",
|
||||
}
|
||||
var buf bytes.Buffer
|
||||
if err := s.templates.ExecuteTemplate(&buf, "configs.html", cfgData); err != nil {
|
||||
t.Fatalf("render configs.html: %v", err)
|
||||
}
|
||||
if !bytes.Contains(buf.Bytes(), []byte("0.87.0")) || !bytes.Contains(buf.Bytes(), []byte("global floor")) {
|
||||
t.Errorf("configs.html missing floor content")
|
||||
if !bytes.Contains(buf.Bytes(), []byte("0.87.0")) {
|
||||
t.Errorf("configs.html missing per-customer floor content")
|
||||
}
|
||||
// The global floor + artifact cards must NOT be on the Customers page anymore.
|
||||
if bytes.Contains(buf.Bytes(), []byte("global floor")) || bytes.Contains(buf.Bytes(), []byte("Day-0 artifacts")) {
|
||||
t.Errorf("configs.html still renders global settings that moved to Configuration")
|
||||
}
|
||||
|
||||
// configuration.html — the Configuration tab now carries the global floor + artifact settings.
|
||||
confData := map[string]interface{}{
|
||||
"CSRFToken": "tok",
|
||||
"CSRFField": s.csrfField(httptest.NewRequest("GET", "/", nil)),
|
||||
"AssetCount": 0,
|
||||
"AssetLastSync": "",
|
||||
"GlobalFloor": "0.86.0",
|
||||
"Artifacts": store.ArtifactManifest{AgentVersion: "0.43.0", GoldenVersion: "0.85.1"},
|
||||
"Flash": "artifacts_set",
|
||||
}
|
||||
buf.Reset()
|
||||
if err := s.templates.ExecuteTemplate(&buf, "configuration.html", confData); err != nil {
|
||||
t.Fatalf("render configuration.html: %v", err)
|
||||
}
|
||||
body := buf.String()
|
||||
for _, want := range []string{"global floor", "Day-0 artifacts", "0.86.0", "0.43.0",
|
||||
"/configuration/global-floor", "/configuration/artifacts", "Artifact manifest saved"} {
|
||||
if !strings.Contains(body, want) {
|
||||
t.Errorf("configuration.html missing %q", want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user