33 lines
632 B
Go
33 lines
632 B
Go
package main
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
"os"
|
|
"path"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestReport(t *testing.T) {
|
|
ctx, can := context.WithTimeout(context.Background(), time.Minute)
|
|
defer can()
|
|
|
|
w := bytes.NewBuffer(nil)
|
|
|
|
db := NewRAM()
|
|
FillWithTestdata(ctx, db, renderAssetPattern, renderDatacenterPattern, renderEventNamePattern)
|
|
s := NewStorage(db)
|
|
|
|
if err := ReportSince(ctx, w, s, time.Now().Add(-1*time.Hour*24*365*20)); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
p := path.Join(os.TempDir(), "test_report.html")
|
|
if env := os.Getenv("TEST_REPORT_PATH"); env != "" {
|
|
p = env
|
|
}
|
|
os.WriteFile(p, w.Bytes(), os.ModePerm)
|
|
t.Log(p)
|
|
}
|