Release 2026.08.02-1
SQLite replaces Postgres, and two fixes from using the thing. - The database is a file under ./storage instead of a second container. Ten members never needed a database server, and the driver is pure Go, so the build stays CGO_ENABLED=0 and the dependency count is unchanged. One bind mount is now the whole backup: no pgdata, no healthcheck-gated depends_on, no startup retry loop. Timestamps are UTC text, idle_ttl is seconds, the divisive/unified boards carry their own stddev, and foreign keys are on by pragma. Tests get a database file each and run without any setup - Invites are copied, not clicked. An invite is something to send, and the anchor opened the join form in the admin's own browser - Feedback asks for more than faults: the footer reads "Ongelmia? Ideoita? Palautetta?" and the page behind it invites ideas rather than only bugs - Kuuntele YouTubessa opens in a new tab, so a half-typed review survives it
This commit is contained in:
+15
-15
@@ -49,7 +49,7 @@ func makeAudio(t *testing.T, path string) {
|
||||
func (a *app) readySubmission(t *testing.T, userID int64) *submission {
|
||||
t.Helper()
|
||||
var id int64
|
||||
err := a.pool.QueryRow(context.Background(), `
|
||||
err := a.db.QueryRowContext(context.Background(), `
|
||||
insert into submissions (user_id, status, title, artist, genre)
|
||||
values ($1, 'ready', 'Testikappale', 'Testiartisti', 'Metal') returning id`,
|
||||
userID).Scan(&id)
|
||||
@@ -58,7 +58,7 @@ func (a *app) readySubmission(t *testing.T, userID int64) *submission {
|
||||
}
|
||||
path := a.tmpPath(id, ".ogg")
|
||||
makeAudio(t, path)
|
||||
if _, err := a.pool.Exec(context.Background(),
|
||||
if _, err := a.db.ExecContext(context.Background(),
|
||||
`update submissions set tmp_path = $2 where id = $1`, id, path); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -96,13 +96,13 @@ func TestPublishIsAllOrNothing(t *testing.T) {
|
||||
t.Fatalf("publish with an unwritable audio dir: status = %d, want 500", w.Code)
|
||||
}
|
||||
var songs, submissions int
|
||||
if err := a.pool.QueryRow(ctx, `select count(*) from songs`).Scan(&songs); err != nil {
|
||||
if err := a.db.QueryRowContext(ctx, `select count(*) from songs`).Scan(&songs); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if songs != 0 {
|
||||
t.Fatalf("orphan song row: %d rows with no audio file", songs)
|
||||
}
|
||||
if err := a.pool.QueryRow(ctx, `select count(*) from submissions`).Scan(&submissions); err != nil {
|
||||
if err := a.db.QueryRowContext(ctx, `select count(*) from submissions`).Scan(&submissions); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if submissions != 1 {
|
||||
@@ -120,13 +120,13 @@ func TestPublishIsAllOrNothing(t *testing.T) {
|
||||
t.Fatalf("publish: status = %d, want 303", w.Code)
|
||||
}
|
||||
var songID int64
|
||||
if err := a.pool.QueryRow(ctx, `select id from songs`).Scan(&songID); err != nil {
|
||||
if err := a.db.QueryRowContext(ctx, `select id from songs`).Scan(&songID); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := os.Stat(a.audioPath(songID)); err != nil {
|
||||
t.Fatalf("published song has no audio file: %v", err)
|
||||
}
|
||||
if err := a.pool.QueryRow(ctx, `select count(*) from submissions`).Scan(&submissions); err != nil {
|
||||
if err := a.db.QueryRowContext(ctx, `select count(*) from submissions`).Scan(&submissions); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if submissions != 0 {
|
||||
@@ -154,7 +154,7 @@ func TestSubmissionQuota(t *testing.T) {
|
||||
check(false, "no submissions")
|
||||
|
||||
for range 4 {
|
||||
if _, err := a.pool.Exec(ctx,
|
||||
if _, err := a.db.ExecContext(ctx,
|
||||
`insert into submissions (user_id, status) values ($1, 'ready')`, id); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -163,7 +163,7 @@ func TestSubmissionQuota(t *testing.T) {
|
||||
|
||||
// Failures never count — yt-dlp rot and bad files are not the submitter's fault.
|
||||
for range 10 {
|
||||
if _, err := a.pool.Exec(ctx,
|
||||
if _, err := a.db.ExecContext(ctx,
|
||||
`insert into submissions (user_id, status) values ($1, 'failed')`, id); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -171,7 +171,7 @@ func TestSubmissionQuota(t *testing.T) {
|
||||
check(false, "failures do not count")
|
||||
|
||||
// A published song still occupies a slot, even though its submission row is gone.
|
||||
if _, err := a.pool.Exec(ctx, `
|
||||
if _, err := a.db.ExecContext(ctx, `
|
||||
insert into songs (title, artist, genre, audio_file, duration_seconds, submitted_by)
|
||||
values ('T', 'A', 'Metal', '1.ogg', 60, $1)`, id); err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -179,8 +179,8 @@ func TestSubmissionQuota(t *testing.T) {
|
||||
check(true, "four in flight plus one published")
|
||||
|
||||
// Yesterday's submissions are outside the window.
|
||||
if _, err := a.pool.Exec(ctx,
|
||||
`update submissions set created_at = now() - interval '25 hours' where user_id = $1`,
|
||||
if _, err := a.db.ExecContext(ctx,
|
||||
`update submissions set created_at = datetime('now', '-25 hours') where user_id = $1`,
|
||||
id); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -194,17 +194,17 @@ func TestRestartRecovery(t *testing.T) {
|
||||
id := a.seedMember(t, "[email protected]")
|
||||
|
||||
for _, status := range []string{"queued", "downloading", "converting"} {
|
||||
if _, err := a.pool.Exec(ctx,
|
||||
if _, err := a.db.ExecContext(ctx,
|
||||
`insert into submissions (user_id, status) values ($1, $2)`, id, status); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
if err := sweep(ctx, a.pool); err != nil {
|
||||
if err := sweep(ctx, a.db); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
var stuck int
|
||||
if err := a.pool.QueryRow(ctx,
|
||||
if err := a.db.QueryRowContext(ctx,
|
||||
`select count(*) from submissions where status <> 'failed'`).Scan(&stuck); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -212,7 +212,7 @@ func TestRestartRecovery(t *testing.T) {
|
||||
t.Fatalf("%d submissions survived the sweep still in flight", stuck)
|
||||
}
|
||||
var msg string
|
||||
if err := a.pool.QueryRow(ctx,
|
||||
if err := a.db.QueryRowContext(ctx,
|
||||
`select status_msg from submissions limit 1`).Scan(&msg); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user