Files
felhom-controller/controller/internal/fillwatch/kept_extra_test.go
T

31 lines
880 B
Go

package fillwatch
import (
"io"
"log"
"path/filepath"
"strings"
"testing"
)
// `09` §3 decision 36 — the drive-full warning names the kept folders on that drive (and only there).
func TestFillwatch_ExtraSentenceRidesTheWarning(t *testing.T) {
var got []Event
w := New(filepath.Join(t.TempDir(), "s.json"), log.New(io.Discard, "", 0),
func() []Target { return []Target{{Path: "/mnt/d", Label: "HDD"}} },
func(string) *Usage { return &Usage{UsedPercent: 97, AvailGB: 3, UsedGB: 97, TotalGB: 100} })
w.SetNotify(func(e Event) { got = append(got, e) })
w.SetExtra(func(tg Target, _ string) string {
if tg.Path == "/mnt/d" {
return "KEPT: Nextcloud (126.0 MB)."
}
return ""
})
if err := w.Check(); err != nil {
t.Fatal(err)
}
if len(got) != 1 || !strings.HasSuffix(got[0].Message, " KEPT: Nextcloud (126.0 MB).") {
t.Fatalf("events = %+v", got)
}
}