This document describes the comprehensive testing strategy for structlint, including validation of our own project structure.
- Purpose: Test core validation logic with controlled scenarios
- Coverage: Directory structure validation, file naming patterns, JSON reporting
- Location: Root directory (legacy compatibility)
- Purpose: Basic CLI functionality tests
- Coverage: Version command, help commands, error handling
- Location:
test/directory
- Purpose: Test validation against various project structure standards
- Coverage:
- Go project standards
- Microservice architecture
- Configuration format validation (YAML/JSON)
- Location:
test/directory
- Purpose: Validate our own project against defined standards
- Coverage:
- Project structure compliance
- Configuration validation
- Real-world scenarios
- Location:
test/directory
- Purpose: End-to-end testing of the CLI tool
- Coverage:
- Self-validation of our project
- Real project structure validation
- Violation detection
- CLI command testing
- Configuration precedence
- Location:
test/directory
Our project follows these defined standards (.structlint.yaml):
Allowed:
.(root)cmd/**(command entry points)internal/**(internal packages)test/**(test files)docs/**(documentation)scripts/**(build scripts)bin/**(built binaries)dist/**(distribution files)
Disallowed:
vendor/**(vendor dependencies)node_modules/**(Node.js dependencies)tmp/**,temp/**(temporary directories).git/**(Git internal files)
Allowed:
*.go,*.mod,*.sum(Go files)*.yaml,*.yml,*.json,*.toml(config files)*.md,*.txt,README*,LICENSE*(documentation)Makefile,Dockerfile*,*.sh(build files).gitignore,.editorconfig,.golangci.yml(tooling)
Disallowed:
*.env*,.env*(environment/secrets)*.log,*.tmp,*.temp(temporary files)*~,*.swp,*.swo(backup/editor files).DS_Store,Thumbs.db(OS files)
.git,.svn,.hg(version control)vendor,node_modules(dependencies)bin,dist,build(build outputs).idea,.vscode(IDE files)*.log,*.tmp(temporary files)
go test ./...# Unit tests only
go test -run TestValidator
# Integration tests only
go test ./test -run TestIntegration
# Self-validation
make test-self# Using Makefile (recommended)
make test-self
# Direct CLI usage
./bin/structlint validate --config .structlint.yaml --json-output validation-report.json✅ 34 checks passed, 0 failures
Our project structure fully complies with the defined standards:
- All directories follow the allowed structure
- All files match allowed naming patterns
- No disallowed patterns detected
- Proper separation of concerns maintained
The self-validation generates a JSON report (validation-report.json):
{
"successes": 34,
"failures": 0,
"errors": []
}- Basic
cmd/andinternal/structure - Essential Go files (
*.go,go.mod,go.sum) - Documentation (
README.md)
- Multiple commands (
cmd/api,cmd/worker) - Service layer (
internal/service) - Repository layer (
internal/repository) - API layer (
internal/api) - Utilities (
pkg/utils)
- Disallowed directories (
tmp/,vendor/) - Disallowed files (
*.env*,*.log,*.tmp) - Proper ignore patterns
- YAML configuration files
- JSON configuration files
- Environment variable precedence
The Makefile provides CI-friendly targets:
# Full CI pipeline
make ci
# Individual steps
make tidy # Clean dependencies
make check # Lint and test
make build # Build binary
make test-self # Self-validation- Self-Validation: Our tool validates its own structure
- Comprehensive Coverage: Tests cover unit, integration, and real-world scenarios
- Standards Enforcement: Clear, documented project standards
- Automated Validation: Makefile targets for easy testing
- Report Generation: JSON reports for analysis and CI integration
- Real-World Testing: Tests against realistic project structures
- Add performance benchmarks
- Test with larger codebases
- Add more project structure templates
- Integration with CI/CD pipelines
- Custom rule validation