package sysx import ( "slices" "testing" ) func TestParseDpkgS(t *testing.T) { out := "openssh-server: /etc/ssh/sshd_config\n" + "diversion by foo from: /usr/bin/caddy\n" + "cron, cron-daemon-common: /etc/cron.d/e2scrub_all\n" paths := []string{"/etc/ssh/sshd_config", "/etc/cron.d/e2scrub_all", "/etc/cron.d/ban-blacklist"} owned := ParseDpkgS(out, paths) if !owned["/etc/ssh/sshd_config"] || !owned["/etc/cron.d/e2scrub_all"] || owned["/etc/cron.d/ban-blacklist"] { t.Fatalf("owned = %v", owned) } } func TestModifiedConffiles(t *testing.T) { out := " /etc/ssh/sshd_config aaa\n" + " /etc/fail2ban/fail2ban.conf bbb\n" + " /etc/old.conf ccc obsolete\n" + " /etc/missing.conf ddd\n" + "\n" sums := map[string]string{ "/etc/ssh/sshd_config": "aaa", // не менялся "/etc/fail2ban/fail2ban.conf": "changed", // изменён "/etc/old.conf": "x", // obsolete — пропускаем } got := modifiedConffiles(out, func(p string) string { return sums[p] }) if !slices.Equal(got, []string{"/etc/fail2ban/fail2ban.conf"}) { t.Fatalf("modified = %v", got) } }