package catalogue import ( "strings" "testing" ) // A module on the shelf from before ADR 0233, which writes its backup lines by hand and declares no // data, is still backed up: its lines are placed as written, each module's under a comment naming it. func TestHandWrittenBackupLinesOfAnOlderModuleArePlaced(t *testing.T) { pg, err := decodeForTest([]byte(`{"module":"pg","version":"1", "resources":[{"id":"dumps","type":"directory","path":"/srv/pg/dumps","mode":"0700"}], "contributions":[{"seat":"node-backup","kind":"backup","content":"run pg-dump-all\npath ${dir:dumps}"}]}`)) if err != nil { t.Fatal(err) } mail, err := decodeForTest([]byte(`{"module":"mail","version":"1", "resources":[{"id":"spool","type":"directory","mode":"0700"}], "contributions":[{"seat":"node-backup","kind":"backup","content":"path ${dir:spool}"}]}`)) if err != nil { t.Fatal(err) } placed, _, err := seatContributions([]Manifest{pg, mail}, Manifest{}, BackupSeat+":"+"backup", Rendering{}, nil, nil) if err != nil { t.Fatal(err) } for _, want := range []string{"# pg\nrun pg-dump-all\npath /srv/pg/dumps\n", "# mail\npath /var/lib/mail/spool\n"} { if !strings.Contains(placed, want) { t.Errorf("placed contributions lack %q:\n%s", want, placed) } } if strings.Contains(placed, "${dir:") { t.Errorf("a directory reached the holder unfilled:\n%s", placed) } }