jet/tests/Makefile
Eli Ribble 9f722d9c05
Don't 'install' jet during tests
Build the output and reference it directly.

Also, use real Makefile syntax for a dependency on a built file to have
proper dependency tracking for updating files
2026-05-14 15:58:39 +00:00

77 lines
3.4 KiB
Makefile

JET = ../cmd/jet/jet
setup: checkout-testdata podman-compose-up
# checkout-testdata will checkout testdata from separate repository into git submodule.
checkout-testdata:
git submodule init
git submodule update
#
checkout-latest-testdata: checkout-testdata
cd ./testdata && git fetch && git checkout master && git pull
# podman-compose-up will download podman image for each of the databases listed in podman-compose.yaml file, and then it will initialize
# database with testdata retrieved in previous step.
# On the first run this action might take couple of minutes. Podman temp data are stored in .podman directory.
podman-compose-up:
podman compose up
init-all:
go run ./init/init.go -testsuite all
init-postgres:
go run ./init/init.go -testsuite postgres
init-mysql:
go run ./init/init.go -testsuite mysql
init-mariadb:
go run ./init/init.go -testsuite mariadb
init-sqlite:
go run ./init/init.go -testsuite sqlite
# jet-gen will call generator on each of the test databases to generate sql builder and model files need to run the tests.
jet-gen-all: jet-gen-postgres jet-gen-mysql jet-gen-mariadb jet-gen-sqlite
ifeq ($(OS),Windows_NT)
target := jet.exe
else
target := jet
endif
$(JET):
cd ../cmd/jet && go build . && cd -
jet-gen-postgres: $(JET)
$(JET) -dsn=postgres://jet:jet@localhost:50901/jetdb?sslmode=disable -schema=dvds -path=./.gentestdata/
$(JET) -dsn=postgres://jet:jet@localhost:50901/jetdb?sslmode=disable -schema=chinook -path=./.gentestdata/
$(JET) -dsn=postgres://jet:jet@localhost:50901/jetdb?sslmode=disable -schema=chinook2 -path=./.gentestdata/
$(JET) -dsn=postgres://jet:jet@localhost:50901/jetdb?sslmode=disable -schema=northwind -path=./.gentestdata/
$(JET) -dsn=postgres://jet:jet@localhost:50901/jetdb?sslmode=disable -schema=test_sample -path=./.gentestdata/
jet-gen-mysql:
$(JET) -source=mysql -dsn="jet:jet@tcp(localhost:50902)/dvds" -path=./.gentestdata/mysql
$(JET) -source=mysql -dsn="jet:jet@tcp(localhost:50902)/dvds2" -path=./.gentestdata/mysql
$(JET) -source=mysql -dsn="jet:jet@tcp(localhost:50902)/test_sample" -path=./.gentestdata/mysql
jet-gen-mariadb:
$(JET) -source=mariadb -dsn="jet:jet@tcp(localhost:50903)/dvds" -path=./.gentestdata/mysql
$(JET) -source=mariadb -dsn="jet:jet@tcp(localhost:50903)/dvds2" -path=./.gentestdata/mysql
$(JET) -source=mariadb -dsn="jet:jet@tcp(localhost:50903)/test_sample" -path=./.gentestdata/mysql
jet-gen-sqlite:
$(JET) -source=sqlite -dsn="./testdata/init/sqlite/chinook.db" -schema=dvds -path=./.gentestdata/sqlite/chinook
$(JET) -source=sqlite -dsn="./testdata/init/sqlite/sakila.db" -schema=dvds -path=./.gentestdata/sqlite/sakila
$(JET) -source=sqlite -dsn="./testdata/init/sqlite/test_sample.db" -schema=dvds -path=./.gentestdata/sqlite/test_sample
jet-gen-cockroach:
$(JET) -dsn=postgres://jet:jet@127.0.0.1:26257/jetdb?sslmode=disable -schema=dvds -path=./.gentestdata/
$(JET) -dsn=postgres://jet:jet@localhost:26257/jetdb?sslmode=disable -schema=chinook -path=./.gentestdata/
$(JET) -dsn=postgres://jet:jet@localhost:26257/jetdb?sslmode=disable -schema=chinook2 -path=./.gentestdata/
$(JET) -dsn=postgres://jet:jet@localhost:26257/jetdb?sslmode=disable -schema=northwind -path=./.gentestdata/
$(JET) -dsn=postgres://jet:jet@localhost:26257/jetdb?sslmode=disable -schema=test_sample -path=./.gentestdata/
# podman-compose-cleanup will stop and remove test containers, volumes, and images.
cleanup:
podman compose down --volumes