Skip to content

Commit 61d789d

Browse files
committed
test: print pg_dump output
1 parent c59cfea commit 61d789d

2 files changed

Lines changed: 8 additions & 39 deletions

File tree

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
--
2-
-- PostgreSQL database dump
3-
--
41

5-
-- Dumped from database version 15.12 (Homebrew)
6-
-- Dumped by pg_dump version 15.12 (Homebrew)
72

83
SET statement_timeout = 0;
94
SET lock_timeout = 0;
@@ -16,16 +11,10 @@ SET xmloption = content;
1611
SET client_min_messages = warning;
1712
SET row_security = off;
1813

19-
--
20-
-- Name: smp_server; Type: SCHEMA; Schema: -; Owner: -
21-
--
2214

2315
CREATE SCHEMA smp_server;
2416

2517

26-
--
27-
-- Name: migrations; Type: TABLE; Schema: smp_server; Owner: -
28-
--
2918

3019
CREATE TABLE smp_server.migrations (
3120
name text NOT NULL,
@@ -34,9 +23,6 @@ CREATE TABLE smp_server.migrations (
3423
);
3524

3625

37-
--
38-
-- Name: msg_queues; Type: TABLE; Schema: smp_server; Owner: -
39-
--
4026

4127
CREATE TABLE smp_server.msg_queues (
4228
recipient_id bytea NOT NULL,
@@ -57,51 +43,30 @@ CREATE TABLE smp_server.msg_queues (
5743
);
5844

5945

60-
--
61-
-- Name: migrations migrations_pkey; Type: CONSTRAINT; Schema: smp_server; Owner: -
62-
--
6346

6447
ALTER TABLE ONLY smp_server.migrations
6548
ADD CONSTRAINT migrations_pkey PRIMARY KEY (name);
6649

6750

68-
--
69-
-- Name: msg_queues msg_queues_pkey; Type: CONSTRAINT; Schema: smp_server; Owner: -
70-
--
7151

7252
ALTER TABLE ONLY smp_server.msg_queues
7353
ADD CONSTRAINT msg_queues_pkey PRIMARY KEY (recipient_id);
7454

7555

76-
--
77-
-- Name: idx_msg_queues_link_id; Type: INDEX; Schema: smp_server; Owner: -
78-
--
7956

8057
CREATE UNIQUE INDEX idx_msg_queues_link_id ON smp_server.msg_queues USING btree (link_id);
8158

8259

83-
--
84-
-- Name: idx_msg_queues_notifier_id; Type: INDEX; Schema: smp_server; Owner: -
85-
--
8660

8761
CREATE UNIQUE INDEX idx_msg_queues_notifier_id ON smp_server.msg_queues USING btree (notifier_id);
8862

8963

90-
--
91-
-- Name: idx_msg_queues_sender_id; Type: INDEX; Schema: smp_server; Owner: -
92-
--
9364

9465
CREATE UNIQUE INDEX idx_msg_queues_sender_id ON smp_server.msg_queues USING btree (sender_id);
9566

9667

97-
--
98-
-- Name: idx_msg_queues_updated_at; Type: INDEX; Schema: smp_server; Owner: -
99-
--
10068

10169
CREATE INDEX idx_msg_queues_updated_at ON smp_server.msg_queues USING btree (deleted_at, updated_at);
10270

10371

104-
--
105-
-- PostgreSQL database dump complete
106-
--
10772

tests/ServerTests/SchemaDump.hs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import Simplex.Messaging.Agent.Store.Shared (Migration (..), MigrationConfirmati
1616
import Simplex.Messaging.Server.QueueStore.Postgres.Migrations (serverMigrations)
1717
import Simplex.Messaging.Util (ifM)
1818
import System.Directory (doesFileExist, removeFile)
19-
import System.Process (readCreateProcess, shell)
19+
import System.Process (readCreateProcess, readCreateProcessWithExitCode, shell)
2020
import Test.Hspec
2121

2222
testDBSchema :: B.ByteString
@@ -39,8 +39,8 @@ testServerDBOpts =
3939

4040
serverSchemaDumpTest :: Spec
4141
serverSchemaDumpTest = do
42-
it "verify and overwrite schema dump" testVerifySchemaDump
43-
it "verify schema down migrations" testSchemaMigrations
42+
fit "verify and overwrite schema dump" testVerifySchemaDump
43+
fit "verify schema down migrations" testSchemaMigrations
4444

4545
testVerifySchemaDump :: IO ()
4646
testVerifySchemaDump = do
@@ -84,6 +84,10 @@ getSchema schemaPath = do
8484
("pg_dump " <> B.unpack testServerDBConnstr <> " --schema " <> B.unpack testDBSchema)
8585
<> " --schema-only --no-comments --no-owner --no-privileges --no-acl --no-subscriptions --no-tablespaces --no-table-access-method > "
8686
<> schemaPath
87-
void $ readCreateProcess (shell cmd) ""
87+
(code, out, err) <- readCreateProcessWithExitCode (shell cmd) ""
88+
print code
89+
putStrLn $ "out: " <> out
90+
putStrLn $ "err: " <> err
91+
void $ readCreateProcess (shell $ "sed -i '' '/^--/d' " <> schemaPath) ""
8892
sch <- readFile schemaPath
8993
sch `deepseq` pure sch

0 commit comments

Comments
 (0)