Fix config module for unit test

Signed-off-by: Asai Neko <sugar@sne.moe>
This commit is contained in:
2025-12-23 20:31:25 +08:00
parent 2d92d5fba7
commit b933522123
5 changed files with 43 additions and 83 deletions

View File

@@ -1,7 +1,8 @@
project_name := "nixcn-cms"
project_dir := justfile_directory()
server_enrty := "main.go"
output_dir := join(justfile_directory(), ".outputs")
client_dir := join(justfile_directory(), "client")
output_dir := join(project_dir, ".outputs")
client_dir := join(project_dir, "client")
exec_path := join(output_dir, project_name)
go_cmd := `realpath $(which go)`
bun_cmd := `realpath $(which bun)`
@@ -9,13 +10,14 @@ bun_cmd := `realpath $(which bun)`
default: clean build run
clean:
rm -rf {{output_dir}}/*
find .outputs -mindepth 1 ! -name config.yaml -exec rm -rf {} +
build:
mkdir -p {{ output_dir }}
{{ go_cmd }} build -o {{ exec_path }}{{ if os() == "windows" { ".exe" } else { "" } }} {{ server_enrty }}
run:
cd {{ output_dir }} && {{ exec_path }}{{ if os() == "windows" { ".exe" } else { "" } }}
cd {{ output_dir }} && CONFIG_PATH={{ output_dir }} {{ exec_path }}{{ if os() == "windows" { ".exe" } else { "" } }}
test:
cd {{output_dir}} && CONFIG_PATH={{output_dir}}/config.yaml GO_ENV=test go test -C .. ./...
cd {{ output_dir }} && CONFIG_PATH={{ output_dir }} GO_ENV=test go test -C .. ./...