carlos / platform Public

Clone
git clone https://amadan.net/carlos/platform

Plain git — no account needed to clone.

Download

Download this file

1package hostbox
2
3import (
4 "os"
5 "path/filepath"
6 "testing"
7)
8
9// Re-review finding 8: the cold restore's purge removes the database's
10// seed marker with it, so a database restored here is never born beside a
11// marker naming another seed.
12func TestPurgeDBRemovesTheSeedMarker(t *testing.T) {
13 db := filepath.Join(t.TempDir(), "a.shop.example.com.db")
14 for _, p := range []string{db, db + "-wal", db + ".gen", db + ".seed"} {
15 if err := os.WriteFile(p, []byte("x"), 0o600); err != nil {
16 t.Fatal(err)
17 }
18 }
19 if err := purgeDB(db); err != nil {
20 t.Fatal(err)
21 }
22 for _, p := range []string{db, db + "-wal", db + ".gen", db + ".seed"} {
23 if _, err := os.Lstat(p); !os.IsNotExist(err) {
24 t.Errorf("%s survived the purge", p)
25 }
26 }
27}
28