30 lines
1.1 KiB
Go
30 lines
1.1 KiB
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"testing"
|
|
)
|
|
|
|
// A module that declares nothing to back up on this machine is not backed up before it moves, and so never held for a
|
|
// backup that cannot run (issue 1945, live on 2026-10-25: redis and searxng on ace were held: "redis declares nothing to
|
|
// back up on this machine"). What node-backup.backed-up answers decides it.
|
|
func TestAModuleWithNothingToBackUpIsNotBackedUp(t *testing.T) {
|
|
for _, c := range []struct {
|
|
said string
|
|
nothing bool
|
|
}{
|
|
{`[{"module":"postgres","runs":1,"paths":["/var/lib/postgres"]}]`, true},
|
|
{`[{"module":"redis","runs":0,"paths":null,"data":[{"item":"cache"}]}]`, true},
|
|
{`[]`, true},
|
|
{`[{"module":"redis","runs":1,"paths":["/var/lib/redis"]}]`, false},
|
|
} {
|
|
nothing, ok := declaresNothingToBackUp(json.RawMessage(c.said), "redis")
|
|
if !ok || nothing != c.nothing {
|
|
t.Errorf("%s: nothing %v (read %v), want %v", c.said, nothing, ok, c.nothing)
|
|
}
|
|
}
|
|
if _, ok := declaresNothingToBackUp(json.RawMessage(`{"error":"x"}`), "redis"); ok {
|
|
t.Error("an answer that is not the list was read")
|
|
}
|
|
}
|