Commit e49b2e7
authored
test: comprehensive test coverage improvement (60% → 82.5%) (#502)
## Summary
- Increase overall statement coverage from ~60% to **82.5%** (+22.5
percentage points)
- Add **7,561 lines** of new test code across **31 test files** covering
all packages
- Fix linter issues (testifylint, goconst, gofumpt, gci, misspell, dupl,
copyloopvar)
- Refactor duplicate enable/disable job handlers into shared
`toggleJobHandler`
- Fix concurrency issues, CSRF race condition, auth panic, and other
bugs found during testing
### Coverage by Package
| Package | Before | After |
|---------|--------|-------|
| `core/domain` | ~70% | **100%** |
| `core/ports` | ~60% | **100%** |
| `metrics` | ~50% | **100%** |
| `test` | ~80% | **100%** |
| `config` | ~90% | **97.8%** |
| `core/adapters/mock` | ~90% | **97.1%** |
| `test/testutil` | ~80% | **96.2%** |
| `core` | ~65% | **90.1%** |
| `middlewares` | ~55% | **88.1%** |
| `web` | ~60% | **84.0%** |
| `cli` | ~50% | **78.9%** |
### New Test Files (26 files)
**Phase 1 - Domain & Ports:**
- `core/domain/{errors,event,exec,image,service}_test.go`
- `core/ports/docker_test.go`, `test/testlogger_test.go`
**Phase 2 - Core Jobs:**
- `core/{runjob,execjob,runservice}_unit_test.go`
- `core/{resilient_job,shutdown_unit,clock_unit}_test.go`
**Phase 3 - Middlewares:**
- Extended:
`middlewares/{webhook,preset,dedup,sanitize,mail,overlap,save,slack}_test.go`
**Phase 4-6 - CLI, Web, Metrics:**
-
`cli/{config_ext,config_validate_ext,daemon_ext,doctor_ext,progress_ext}_test.go`
- `web/{auth_secure_ext,server_ext}_test.go`,
`metrics/prometheus_ext_test.go`
**Phase 7-8 - Docker Adapter & Partials:**
- `core/adapters/docker/{container_convert,service_convert}_test.go`
- Extended: `cli/config_decode_test.go`,
`middlewares/{restore,preset_cache,webhook_config,webhook_security}_test.go`
## Test plan
- [x] All tests pass: `go test ./... -count=1` (14 packages OK)
- [x] Linter clean: `golangci-lint run ./...` (0 issues)
- [x] Coverage verified: 82.5% total statement coverage
- [x] No race conditions: tests use `t.Parallel()` throughoutFile tree
51 files changed
+8492
-84
lines changed- cli
- config
- core
- adapters/docker
- domain
- ports
- metrics
- middlewares
- test
- testutil
- web
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
51 files changed
+8492
-84
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
468 | 468 | | |
469 | 469 | | |
470 | 470 | | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
0 commit comments