- HPE iLO AHS parser: handle truncated last entry gracefully, recognize Alletra product line, expand event type/severity inference, trim iLO frame separators from event messages - Fix event_logs always 0 in Reanimator export: normalizeEventLogSource now maps "HPE iLO" → "bmc" - Fix chart JS not loading in LOGPile: rewriteChartStaticPaths now also rewrites src="/static/view.js" → /chart/static/view.js - Add "Logs Export" button (CSV, semicolon-delimited, UTF-8 BOM) and remove PDF button - Fix collector test broken by pciids rename of Intel VMD device - Update submodules: chart v2.7, pciids, bible Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
73 lines
1.7 KiB
Go
73 lines
1.7 KiB
Go
package server
|
|
|
|
import (
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
|
|
"git.mchus.pro/mchus/logpile/internal/models"
|
|
)
|
|
|
|
func TestHandleChartCurrent_RendersCurrentReanimatorSnapshot(t *testing.T) {
|
|
s := New(Config{})
|
|
s.SetResult(&models.AnalysisResult{
|
|
SourceType: models.SourceTypeArchive,
|
|
Filename: "example.zip",
|
|
CollectedAt: time.Date(2026, 3, 16, 10, 0, 0, 0, time.UTC),
|
|
Hardware: &models.HardwareConfig{
|
|
BoardInfo: models.BoardInfo{
|
|
ProductName: "SYS-TEST",
|
|
SerialNumber: "SN123",
|
|
},
|
|
CPUs: []models.CPU{
|
|
{
|
|
Socket: 1,
|
|
Model: "Xeon Gold",
|
|
Cores: 32,
|
|
},
|
|
},
|
|
},
|
|
})
|
|
|
|
req := httptest.NewRequest(http.MethodGet, "/chart/current", nil)
|
|
rec := httptest.NewRecorder()
|
|
|
|
s.mux.ServeHTTP(rec, req)
|
|
|
|
if rec.Code != http.StatusOK {
|
|
t.Fatalf("expected 200, got %d", rec.Code)
|
|
}
|
|
body := rec.Body.String()
|
|
if !strings.Contains(body, "SYS-TEST - SN123") {
|
|
t.Fatalf("expected chart title in body, got %q", body)
|
|
}
|
|
if !strings.Contains(body, `/chart/static/view.css`) {
|
|
t.Fatalf("expected rewritten chart css path, got %q", body)
|
|
}
|
|
if !strings.Contains(body, `/chart/static/view.js`) {
|
|
t.Fatalf("expected rewritten chart js path, got %q", body)
|
|
}
|
|
if !strings.Contains(body, "Snapshot Metadata") {
|
|
t.Fatalf("expected rendered chart output, got %q", body)
|
|
}
|
|
}
|
|
|
|
func TestHandleChartCurrent_RendersEmptyViewerWithoutResult(t *testing.T) {
|
|
s := New(Config{})
|
|
|
|
req := httptest.NewRequest(http.MethodGet, "/chart/current", nil)
|
|
rec := httptest.NewRecorder()
|
|
|
|
s.mux.ServeHTTP(rec, req)
|
|
|
|
if rec.Code != http.StatusOK {
|
|
t.Fatalf("expected 200, got %d", rec.Code)
|
|
}
|
|
body := rec.Body.String()
|
|
if !strings.Contains(body, "Snapshot Viewer") {
|
|
t.Fatalf("expected empty chart viewer, got %q", body)
|
|
}
|
|
}
|