35 lines
1.4 KiB
Go
35 lines
1.4 KiB
Go
package notify
|
|
|
|
import (
|
|
"encoding/json"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// D62 — restore_copy_deleted: info (the hub's vocabulary), the operator message only (no household sentence — the hub
|
|
// bars the type from customers too), and the details carry who, app, the restore's date and the size.
|
|
func TestD62_RestoreCopyDeletedEvent(t *testing.T) {
|
|
n := &Notifier{}
|
|
var et, sev, msg, cust string
|
|
var det []byte
|
|
n.pushFn = func(eventType, severity, message, customer string, details interface{}) {
|
|
et, sev, msg, cust = eventType, severity, message, customer
|
|
det, _ = json.Marshal(details)
|
|
}
|
|
n.NotifyRestoreCopyDeleted(RestoreCopyDeletedDetails{App: "vikunja", RestoreAt: "2026-10-29T08:00:00Z", SizeBytes: 4096,
|
|
Who: "the household (dashboard sign-in) from 192.168.0.5", Path: "/x/backups/restore-undo/vikunja/20261029T080000Z"})
|
|
if et != "restore_copy_deleted" || sev != "info" || cust != "" {
|
|
t.Fatalf("type=%q severity=%q customer=%q", et, sev, cust)
|
|
}
|
|
for _, want := range []string{"vikunja", "2026-10-29T08:00:00Z", "4096", "the household"} {
|
|
if !strings.Contains(msg, want) {
|
|
t.Fatalf("message %q lacks %q", msg, want)
|
|
}
|
|
}
|
|
for _, want := range []string{`"app":"vikunja"`, `"restore_at":"2026-10-29T08:00:00Z"`, `"size_bytes":4096`, `"who":"the household`} {
|
|
if !strings.Contains(string(det), want) {
|
|
t.Fatalf("details %s lack %s", det, want)
|
|
}
|
|
}
|
|
}
|