mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-02-18 00:17:39 +01:00
Replace manual resource ID entry with a searchable, filterable resource picker that uses live WebSocket state. Support selecting multiple resources (up to 50) for combined fleet reports. Multi-resource PDFs include a cover page, fleet summary table with aggregate health status, and condensed per-resource detail pages with overlaid CPU/memory charts. Multi-resource CSVs include a summary section followed by interleaved time-series data with resource columns. New POST /api/admin/reports/generate-multi endpoint handles multi-resource requests while the existing single-resource GET endpoint remains unchanged. Also fixes resource ID validation regex to allow colons used in VM/container IDs (e.g., "instance:node:vmid").
31 lines
606 B
Go
31 lines
606 B
Go
package reporting
|
|
|
|
import "testing"
|
|
|
|
type fakeEngine struct {
|
|
called bool
|
|
}
|
|
|
|
func (f *fakeEngine) Generate(req MetricReportRequest) ([]byte, string, error) {
|
|
f.called = true
|
|
return []byte("ok"), "text/plain", nil
|
|
}
|
|
|
|
func (f *fakeEngine) GenerateMulti(req MultiReportRequest) ([]byte, string, error) {
|
|
f.called = true
|
|
return []byte("ok"), "text/plain", nil
|
|
}
|
|
|
|
func TestSetGetEngine(t *testing.T) {
|
|
engine := &fakeEngine{}
|
|
SetEngine(engine)
|
|
if GetEngine() != engine {
|
|
t.Fatal("expected engine to be set")
|
|
}
|
|
|
|
SetEngine(nil)
|
|
if GetEngine() != nil {
|
|
t.Fatal("expected engine to be cleared")
|
|
}
|
|
}
|