Files
nofx/Makefile
Liu Xiang Qian 1fdf8142da test: Add minimal UT infrastructure and fix Issue #227
This commit sets up a minimal, KISS-principle testing infrastructure
for both backend and frontend, and includes the fix for Issue #227.

Backend Changes:
- Add Makefile with test commands (test, test-backend, test-frontend, test-coverage)
- Add example test: config/database_test.go
- Fix Go 1.25 printf format string warnings in trader/auto_trader.go
  (Changed log.Printf to log.Print for non-format strings)
- All backend tests pass ✓

Frontend Changes:
- Add Vitest configuration: web/vitest.config.ts (minimal setup)
- Add test utilities: web/src/test/test-utils.tsx
- Add example test: web/src/App.test.tsx
- Add dependencies: vitest, jsdom, @testing-library/react
- All frontend tests pass ✓

Issue #227 Fix:
- Fix AITradersPage to allow editing traders with disabled models/exchanges
- Change validation to use allModels/allExchanges instead of enabledModels/enabledExchanges
- Add comprehensive tests in web/src/components/AITradersPage.test.tsx
- Fixes: https://github.com/tinkle-community/nofx/issues/227

CI/CD:
- Add GitHub Actions workflow: .github/workflows/test.yml
- Non-blocking tests (continue-on-error: true)
- Runs on push/PR to main and dev branches

Test Results:
- Backend: 1 test passing
- Frontend: 5 tests passing (including 4 for Issue #227)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: tinkle-community <tinklefund@gmail.com>
2025-11-02 10:58:31 +08:00

154 lines
4.0 KiB
Makefile

# NOFX Makefile for testing and development
.PHONY: help test test-backend test-frontend test-coverage clean
# Default target
help:
@echo "NOFX Testing & Development Commands"
@echo ""
@echo "Testing:"
@echo " make test - Run all tests (backend + frontend)"
@echo " make test-backend - Run backend tests only"
@echo " make test-frontend - Run frontend tests only"
@echo " make test-coverage - Generate backend coverage report"
@echo ""
@echo "Build:"
@echo " make build - Build backend binary"
@echo " make build-frontend - Build frontend"
@echo ""
@echo "Clean:"
@echo " make clean - Clean build artifacts and test cache"
# =============================================================================
# Testing
# =============================================================================
# Run all tests
test:
@echo "🧪 Running backend tests..."
go test -v ./...
@echo ""
@echo "🧪 Running frontend tests..."
cd web && npm run test
@echo "✅ All tests completed"
# Backend tests only
test-backend:
@echo "🧪 Running backend tests..."
go test -v ./...
# Frontend tests only
test-frontend:
@echo "🧪 Running frontend tests..."
cd web && npm run test
# Coverage report
test-coverage:
@echo "📊 Generating coverage..."
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.html
@echo "✅ Backend coverage: coverage.html"
# =============================================================================
# Build
# =============================================================================
# Build backend binary
build:
@echo "🔨 Building backend..."
go build -o nofx
@echo "✅ Backend built: ./nofx"
# Build frontend
build-frontend:
@echo "🔨 Building frontend..."
cd web && npm run build
@echo "✅ Frontend built: ./web/dist"
# =============================================================================
# Development
# =============================================================================
# Run backend in development mode
run:
@echo "🚀 Starting backend..."
go run main.go
# Run frontend in development mode
run-frontend:
@echo "🚀 Starting frontend dev server..."
cd web && npm run dev
# Format Go code
fmt:
@echo "🎨 Formatting Go code..."
go fmt ./...
@echo "✅ Code formatted"
# Lint Go code (requires golangci-lint)
lint:
@echo "🔍 Linting Go code..."
golangci-lint run
@echo "✅ Linting completed"
# =============================================================================
# Clean
# =============================================================================
clean:
@echo "🧹 Cleaning..."
rm -f nofx
rm -f coverage.out coverage.html
rm -rf web/dist
go clean -testcache
@echo "✅ Cleaned"
# =============================================================================
# Docker
# =============================================================================
# Build Docker images
docker-build:
@echo "🐳 Building Docker images..."
docker compose build
@echo "✅ Docker images built"
# Run Docker containers
docker-up:
@echo "🐳 Starting Docker containers..."
docker compose up -d
@echo "✅ Docker containers started"
# Stop Docker containers
docker-down:
@echo "🐳 Stopping Docker containers..."
docker compose down
@echo "✅ Docker containers stopped"
# View Docker logs
docker-logs:
docker compose logs -f
# =============================================================================
# Dependencies
# =============================================================================
# Download Go dependencies
deps:
@echo "📦 Downloading Go dependencies..."
go mod download
@echo "✅ Dependencies downloaded"
# Update Go dependencies
deps-update:
@echo "📦 Updating Go dependencies..."
go get -u ./...
go mod tidy
@echo "✅ Dependencies updated"
# Install frontend dependencies
deps-frontend:
@echo "📦 Installing frontend dependencies..."
cd web && npm install
@echo "✅ Frontend dependencies installed"