forked from naskya/firefish
dev: add test for neko/revert.sql in Makefile
This commit is contained in:
parent
25a1bbea7b
commit
52fea1ddcf
1 changed files with 26 additions and 2 deletions
28
Makefile
28
Makefile
|
@ -22,9 +22,33 @@ MIGRATIONS += $(foreach dir, $(RUST_DIR)/migration/src, $(wildcard $(dir)/*))
|
|||
UPDATE_SCRIPTS := update.sh
|
||||
UPDATE_SCRIPTS += $(foreach dir, neko/update, $(wildcard $(dir)/*))
|
||||
|
||||
POSTGRES_USER := firefish
|
||||
POSTGRES_DB := firefish_db
|
||||
POSTGRES_PASSWORD := password
|
||||
POSTGRES_HOST_PORT := localhost:25432
|
||||
|
||||
|
||||
.PHONY: pre-commit
|
||||
pre-commit: format shellcheck update-lockfiles regenerate-entities neko/index.js rust-lint
|
||||
pre-commit: test format shellcheck update-lockfiles regenerate-entities neko/index.js rust-lint
|
||||
|
||||
|
||||
.PHONY: test
|
||||
test: test-revert
|
||||
|
||||
|
||||
.PHONY: test-revert
|
||||
test-revert: $(T)/test-revert
|
||||
|
||||
$(T)/test-revert: neko/revert.sql $(MIGRATIONS)
|
||||
cd dev && \
|
||||
podman-compose exec db \
|
||||
psql \
|
||||
--echo-all \
|
||||
--user=$(POSTGRES_USER) \
|
||||
--dbname=$(POSTGRES_DB) \
|
||||
--set='ON_ERROR_STOP=1' \
|
||||
--command="$$(printf 'BEGIN;\n%s\nROLLBACK;' "$$(cat ../neko/revert.sql)")"
|
||||
touch $@
|
||||
|
||||
|
||||
.PHONY: update-lockfiles
|
||||
|
@ -74,7 +98,7 @@ $(T)/regenerate-entities: $(MIGRATIONS)
|
|||
cd $(RUST_DIR) && \
|
||||
sea-orm-cli generate entity \
|
||||
--output-dir='src/model/entity' \
|
||||
--database-url='postgres://firefish:password@localhost:25432/firefish_db' \
|
||||
--database-url='postgres://$(POSTGRES_USER):$(POSTGRES_PASSWORD)@$(POSTGRES_HOST_PORT)/$(POSTGRES_DB)' \
|
||||
--date-time-crate='chrono' \
|
||||
--model-extra-attributes='NAPI_EXTRA_ATTR_PLACEHOLDER' && \
|
||||
for file in src/model/entity/*; do \
|
||||
|
|
Loading…
Reference in a new issue