1
0
Fork 1
mirror of https://example.com synced 2024-11-22 11:16:38 +09:00

dev: add test for neko/revert.sql in Makefile

This commit is contained in:
naskya 2024-01-22 04:14:31 +09:00
parent 25a1bbea7b
commit 52fea1ddcf
Signed by: naskya
GPG key ID: 712D413B3A9FED5C

View file

@ -22,9 +22,33 @@ MIGRATIONS += $(foreach dir, $(RUST_DIR)/migration/src, $(wildcard $(dir)/*))
UPDATE_SCRIPTS := update.sh UPDATE_SCRIPTS := update.sh
UPDATE_SCRIPTS += $(foreach dir, neko/update, $(wildcard $(dir)/*)) 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 .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 .PHONY: update-lockfiles
@ -74,7 +98,7 @@ $(T)/regenerate-entities: $(MIGRATIONS)
cd $(RUST_DIR) && \ cd $(RUST_DIR) && \
sea-orm-cli generate entity \ sea-orm-cli generate entity \
--output-dir='src/model/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' \ --date-time-crate='chrono' \
--model-extra-attributes='NAPI_EXTRA_ATTR_PLACEHOLDER' && \ --model-extra-attributes='NAPI_EXTRA_ATTR_PLACEHOLDER' && \
for file in src/model/entity/*; do \ for file in src/model/entity/*; do \