carlos / platform Public

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

Plain git — no account needed to clone.

Download

Download this file

1package activator
2
3import (
4 "os"
5 "path/filepath"
6 "testing"
7)
8
9// Final review carry item: the full purge (a move's cut) removes the
10// database and its <db>.seed marker with it; the partial purge (a restore's
11// pre-clean, where the database is already gone) keeps both as it found
12// them.
13func TestPurgeLocalDBArtifactsRemovesTheMarkerWithTheDatabase(t *testing.T) {
14 for _, full := range []bool{false, true} {
15 dir := t.TempDir()
16 db := filepath.Join(dir, "a.shop.example.com.db")
17 for _, p := range []string{db, db + "-wal", db + "-shm", db + SeedMarkerSuffix} {
18 if err := os.WriteFile(p, []byte("x"), 0o600); err != nil {
19 t.Fatal(err)
20 }
21 }
22 PurgeLocalDBArtifacts(db, full)
23 for _, p := range []string{db + "-wal", db + "-shm"} {
24 if _, err := os.Lstat(p); !os.IsNotExist(err) {
25 t.Errorf("full %v: %s survived", full, p)
26 }
27 }
28 for _, p := range []string{db, db + SeedMarkerSuffix} {
29 if _, err := os.Lstat(p); os.IsNotExist(err) != full {
30 t.Errorf("full %v: %s gone %v, want gone %v", full, p, os.IsNotExist(err), full)
31 }
32 }
33 }
34}
35