34 lines
909 B
Go
34 lines
909 B
Go
package main
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestNewestKernel(t *testing.T) {
|
|
output := "proxmox-kernel-6.8 6.8.12-5\nproxmox-kernel-6.14 6.14.8-2"
|
|
if got := newestKernel(output); got != "6.14.8-2" {
|
|
t.Fatalf("unexpected newest kernel: %s", got)
|
|
}
|
|
}
|
|
|
|
func TestNextZFSScrubCron(t *testing.T) {
|
|
path := filepath.Join(t.TempDir(), "zfs")
|
|
if err := os.WriteFile(path, []byte("24 0 8-14 * * root /usr/lib/zfs-linux/scrub\n"), 0600); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
now := time.Date(2026, 8, 1, 12, 0, 0, 0, time.UTC)
|
|
if got := nextZFSScrubCron(path, now); got != "Sun 2026-08-09 00:24 UTC" {
|
|
t.Fatalf("unexpected cron scrub: %s", got)
|
|
}
|
|
}
|
|
|
|
func TestNextScrubTimer(t *testing.T) {
|
|
line := "Sun 2026-08-02 00:24:00 MSK 1 day left zfs-scrub-weekly@tank.timer"
|
|
if got := nextScrubTimer(line); got != "Sun 2026-08-02 00:24:00 MSK" {
|
|
t.Fatalf("unexpected scrub: %s", got)
|
|
}
|
|
}
|