Phase 5-7: README, Makefile, unit tests

- README.md: full usage docs
- Makefile: build/install/uninstall/test/lint/clean targets
- config/config_test.go: 7 tests (load, save, find, add, roundtrip, invalid yaml)
- runtime/runtime_test.go: 6 tests (get, available, ListRunning graceful degradation)
- systemd/generator_test.go: 7 tests (ServiceName, Generate system/user/custom/docker/unknown, buildExecCommands)
- fix: docker/podman ListRunning returns nil (not error) when daemon unavailable
- fix: invalid YAML test uses tab-indent which is genuinely unparseable
This commit is contained in:
2026-04-03 14:50:36 +02:00
parent 203e8e3f04
commit 5078558d01
7 changed files with 576 additions and 2 deletions

45
Makefile Normal file
View File

@@ -0,0 +1,45 @@
BINARY := unitdore
INSTALL_DIR := /usr/local/bin
CONFIG_DIR := /etc/unitdore
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
LDFLAGS := -ldflags "-X main.version=$(VERSION)"
.PHONY: all build install uninstall test lint clean
all: build
## build: compile the binary
build:
go build $(LDFLAGS) -o $(BINARY) .
## install: install binary and create config dir
install: build
install -Dm755 $(BINARY) $(INSTALL_DIR)/$(BINARY)
mkdir -p $(CONFIG_DIR)
@echo "Installed to $(INSTALL_DIR)/$(BINARY)"
@echo "Config dir: $(CONFIG_DIR)"
## uninstall: remove binary
uninstall:
rm -f $(INSTALL_DIR)/$(BINARY)
@echo "Removed $(INSTALL_DIR)/$(BINARY)"
## test: run all unit tests
test:
go test ./... -v
## test-short: run tests without verbose output
test-short:
go test ./...
## lint: run go vet
lint:
go vet ./...
## clean: remove built binary
clean:
rm -f $(BINARY)
## help: show this help
help:
@grep -E '^## ' Makefile | sed 's/## / /'