1
1
# Directory paths
2
- SRC_DIR := src
3
- TEST_DIR := tests
4
- BUILD_DIR := dist
2
+ SQL_DIR := sql
3
+ TEST_DIR := test
5
4
PG_HOST := localhost
6
5
PG_PORT := 54322
7
6
PG_USER := postgres
8
7
PG_DB := postgres
9
8
PG_PASSWORD := postgres
10
9
10
+ EXTENSION := keyhippo
11
+ EXTVERSION := 1.2.4
12
+
11
13
# Default goal
12
14
.DEFAULT_GOAL := help
13
15
@@ -19,18 +21,19 @@ help:
19
21
@echo " test - Run tests"
20
22
@echo " pg_tap - Run pg_tap tests"
21
23
@echo " cleanup - Remove files created during testing"
24
+ @echo " benchmark - Run benchmark tests"
22
25
23
26
# Reset database
24
27
.PHONY : reset-database
25
28
reset-database :
26
29
@echo " Resetting..."
27
- PGPASSWORD=$(PG_PASSWORD ) psql -h $(PG_HOST ) -p $(PG_PORT ) -U $(PG_USER ) -d $(PG_DB ) -v ON_ERROR_STOP=1 -f $(TEST_DIR ) /reset.sql
30
+ PGPASSWORD=$(PG_PASSWORD ) psql -h $(PG_HOST ) -p $(PG_PORT ) -U $(PG_USER ) -d $(PG_DB ) -v ON_ERROR_STOP=1 -f $(TEST_DIR ) /utils/ reset.sql
28
31
29
32
# Set up Supabase
30
33
.PHONY : setup-supabase
31
34
setup-supabase :
32
35
@echo " Setting up Supabase..."
33
- @cd tests && \
36
+ @cd $( TEST_DIR ) && \
34
37
supabase start && \
35
38
eval $$(supabase status -o env ) && \
36
39
echo " SUPABASE_URL=$$ API_URL" > .env.test && \
@@ -40,10 +43,15 @@ setup-supabase:
40
43
@echo " CREATE EXTENSION IF NOT EXISTS pgjwt;" >> create_schema.sql
41
44
@echo " CREATE SCHEMA IF NOT EXISTS keyhippo;" >> create_schema.sql
42
45
PGPASSWORD=$(PG_PASSWORD ) psql -h $(PG_HOST ) -p $(PG_PORT ) -U $(PG_USER ) -d $(PG_DB ) -v ON_ERROR_STOP=1 -f create_schema.sql
43
- @for file in $$(find extension/ -type f -name "keyhippo*--*.sql" | sort -V ) ; do \
44
- echo " Applying migration: $$ file" ; \
45
- PGPASSWORD=$(PG_PASSWORD ) psql -h $(PG_HOST ) -p $(PG_PORT ) -U $(PG_USER ) -d $(PG_DB ) -v ON_ERROR_STOP=1 -f " $$ file" ; \
46
- done
46
+ PGPASSWORD=$(PG_PASSWORD ) psql -h $(PG_HOST ) -p $(PG_PORT ) -U $(PG_USER ) -d $(PG_DB ) -v ON_ERROR_STOP=1 -f $(SQL_DIR ) /$(EXTENSION ) .sql
47
+ @if ls $(SQL_DIR ) /$(EXTENSION ) --* --* .sql 1> /dev/null 2>&1 ; then \
48
+ for file in $( SQL_DIR) /$( EXTENSION) --* --* .sql; do \
49
+ echo " Applying migration: $$ file" ; \
50
+ PGPASSWORD=$(PG_PASSWORD ) psql -h $(PG_HOST ) -p $(PG_PORT ) -U $(PG_USER ) -d $(PG_DB ) -v ON_ERROR_STOP=1 -f " $$ file" ; \
51
+ done \
52
+ else \
53
+ echo " No upgrade migrations found. Skipping." ; \
54
+ fi
47
55
48
56
# Apply integration test migrations
49
57
.PHONY : apply-integration-test-migrations
@@ -76,7 +84,7 @@ pg_tap:
76
84
.PHONY : benchmark
77
85
benchmark :
78
86
@echo " Running benchmark..."
79
- PGPASSWORD=$(PG_PASSWORD ) psql -h $(PG_HOST ) -p $(PG_PORT ) -U $(PG_USER ) -d $(PG_DB ) -v ON_ERROR_STOP=1 -f $(TEST_DIR ) /bench.sql
87
+ PGPASSWORD=$(PG_PASSWORD ) psql -h $(PG_HOST ) -p $(PG_PORT ) -U $(PG_USER ) -d $(PG_DB ) -v ON_ERROR_STOP=1 -f $(TEST_DIR ) /utils/ bench.sql
80
88
81
89
# Clean up files created during testing
82
90
.PHONY : cleanup
0 commit comments