Phase 10, part 9: the server package

compose.server.yaml runs Supermarket behind Caddy (HTTPS from Let's
Encrypt, Caddy's own CA or the team's), with Postgres on an internal
network and a nightly pg_dump kept two weeks. install-server.sh asks for
the domain, certificate and mail server, makes the secret key and database
password, starts it all and prints the setup link. Settings → Backups lists
the dumps on a server, and how the operator restores one. Checked end to
end in Docker.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-25 09:37:34 -07:00
co-authored by Claude Opus 5.5
parent c8964cec12
commit da16736fb4
15 changed files with 532 additions and 17 deletions
+21
View File
@@ -14,6 +14,7 @@ import (
"time"
"supermarket/internal/backup"
"supermarket/internal/users"
)
func TestBackupsPage(t *testing.T) {
@@ -125,3 +126,23 @@ func TestBackupUpload(t *testing.T) {
t.Errorf("temporary files left: %v", left)
}
}
func TestServerBackupsPage(t *testing.T) {
if !db.OnPostgres() {
t.Skip("the server's backups page is Postgres's")
}
s, h := newServerEdition(t)
dir := t.TempDir()
s.Config.PGBackups = dir
os.WriteFile(filepath.Join(dir, "supermarket-2026-11-24.dump"), []byte("x"), 0o600)
os.WriteFile(filepath.Join(dir, "notes.txt"), []byte("x"), 0o600)
owner := addUser(t, s, "owner@example.com", users.Owner, nil)
c := sessionFor(t, s, owner)
body := as(h, c, http.MethodGet, "/settings/backups", nil).Body.String()
if !strings.Contains(body, "supermarket-2026-11-24.dump") || strings.Contains(body, "notes.txt") || !strings.Contains(body, "pg_restore") {
t.Errorf("page: %s", body)
}
if rec := as(h, c, http.MethodPost, "/settings/backups/now", url.Values{}); rec.Code != http.StatusNotFound {
t.Errorf("back up now on Postgres: %d", rec.Code)
}
}