Skip to content

Commit 2410653

Browse files
committed
fix: integrations tests concurency + missing column due a hardcoded database struct (removed)
1 parent c738763 commit 2410653

File tree

1 file changed

+2
-64
lines changed

1 file changed

+2
-64
lines changed

backend/internal/presentation/api/admin/handler_test.go

Lines changed: 2 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -20,71 +20,9 @@ import (
2020
)
2121

2222
func setupTestDB(t *testing.T) *database.TestDB {
23+
// Use database.SetupTestDB which applies all migrations automatically
24+
// This ensures test schema matches production schema
2325
testDB := database.SetupTestDB(t)
24-
25-
// Create tables
26-
schema := `
27-
DROP TABLE IF EXISTS reminder_logs CASCADE;
28-
DROP TABLE IF EXISTS expected_signers CASCADE;
29-
DROP TABLE IF EXISTS signatures CASCADE;
30-
DROP TABLE IF EXISTS documents CASCADE;
31-
32-
CREATE TABLE documents (
33-
doc_id TEXT PRIMARY KEY,
34-
title TEXT NOT NULL DEFAULT '',
35-
url TEXT NOT NULL DEFAULT '',
36-
checksum TEXT NOT NULL DEFAULT '',
37-
checksum_algorithm TEXT NOT NULL DEFAULT 'SHA-256',
38-
description TEXT NOT NULL DEFAULT '',
39-
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
40-
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
41-
created_by TEXT NOT NULL DEFAULT ''
42-
);
43-
44-
CREATE TABLE signatures (
45-
id BIGSERIAL PRIMARY KEY,
46-
doc_id TEXT NOT NULL,
47-
user_sub TEXT NOT NULL,
48-
user_email TEXT NOT NULL,
49-
user_name TEXT NOT NULL DEFAULT '',
50-
signed_at TIMESTAMPTZ NOT NULL,
51-
payload_hash TEXT NOT NULL,
52-
signature TEXT NOT NULL,
53-
nonce TEXT NOT NULL,
54-
created_at TIMESTAMPTZ DEFAULT now(),
55-
referer TEXT,
56-
prev_hash TEXT,
57-
UNIQUE (doc_id, user_sub)
58-
);
59-
60-
CREATE TABLE expected_signers (
61-
id BIGSERIAL PRIMARY KEY,
62-
doc_id TEXT NOT NULL,
63-
email TEXT NOT NULL,
64-
name TEXT NOT NULL DEFAULT '',
65-
added_at TIMESTAMPTZ NOT NULL DEFAULT now(),
66-
added_by TEXT NOT NULL,
67-
notes TEXT,
68-
UNIQUE (doc_id, email)
69-
);
70-
71-
CREATE TABLE reminder_logs (
72-
id BIGSERIAL PRIMARY KEY,
73-
doc_id TEXT NOT NULL,
74-
recipient_email TEXT NOT NULL,
75-
sent_at TIMESTAMPTZ NOT NULL DEFAULT now(),
76-
sent_by TEXT NOT NULL,
77-
template_used TEXT NOT NULL,
78-
status TEXT NOT NULL,
79-
error_message TEXT
80-
);
81-
`
82-
83-
_, err := testDB.DB.Exec(schema)
84-
if err != nil {
85-
t.Fatalf("Failed to create test schema: %v", err)
86-
}
87-
8826
return testDB
8927
}
9028

0 commit comments

Comments
 (0)