Add testing documentation to README
This commit is contained in:
58
README.md
58
README.md
@@ -230,8 +230,64 @@ go run cmd/server/main.go
|
|||||||
# Build
|
# Build
|
||||||
go build -o server cmd/server/main.go
|
go build -o server cmd/server/main.go
|
||||||
|
|
||||||
# Test
|
# Run all tests
|
||||||
go test ./...
|
go test ./...
|
||||||
|
|
||||||
|
# Run tests with verbose output
|
||||||
|
go test ./... -v
|
||||||
|
|
||||||
|
# Run specific test package
|
||||||
|
go test ./internal/handlers -v
|
||||||
|
go test ./internal/database -v
|
||||||
|
go test ./tests/integration -v
|
||||||
|
|
||||||
|
# Run with coverage
|
||||||
|
go test ./... -cover
|
||||||
|
```
|
||||||
|
|
||||||
|
## Testing
|
||||||
|
|
||||||
|
The project includes comprehensive tests:
|
||||||
|
|
||||||
|
### Unit Tests
|
||||||
|
- **config**: Configuration loading and validation (11 tests)
|
||||||
|
- **database**: Database operations and models (9 tests)
|
||||||
|
- **handlers**: Handler logic, custom filters, and validation (36 tests)
|
||||||
|
|
||||||
|
### Integration Tests
|
||||||
|
Full end-to-end tests using:
|
||||||
|
- **Mock Technitium Server**: Simulates DNS API without external dependencies
|
||||||
|
- **SQLite**: In-memory/temp database for isolated testing
|
||||||
|
- **Gin Test Server**: HTTP testing without network
|
||||||
|
|
||||||
|
Integration tests cover:
|
||||||
|
- Space claiming workflow
|
||||||
|
- Subdomain availability checking
|
||||||
|
- Profanity filtering
|
||||||
|
- Custom DWS/Tanishq Dubey trademark filtering
|
||||||
|
- DynDNS2 protocol updates
|
||||||
|
- Full end-to-end workflows
|
||||||
|
|
||||||
|
### Test Files
|
||||||
|
```
|
||||||
|
internal/config/config_test.go # Config tests
|
||||||
|
internal/database/db_test.go # Database tests
|
||||||
|
internal/handlers/handlers_test.go # Handler unit tests
|
||||||
|
internal/handlers/validation.go # Custom validators
|
||||||
|
internal/testutil/mock_technitium.go # Mock DNS server
|
||||||
|
tests/integration/integration_test.go # Integration tests
|
||||||
|
```
|
||||||
|
|
||||||
|
### Running Integration Tests
|
||||||
|
```bash
|
||||||
|
# Run all integration tests
|
||||||
|
go test ./tests/integration -v
|
||||||
|
|
||||||
|
# Run specific integration test
|
||||||
|
go test ./tests/integration -v -run TestIntegration_FullWorkflow
|
||||||
|
|
||||||
|
# Run with timeout
|
||||||
|
go test ./tests/integration -v -timeout 30s
|
||||||
```
|
```
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|||||||
Reference in New Issue
Block a user