Aller au contenu
login
arrow_backRetour aux issues
kubestellar/kubestellar-mcp #582

[quality] Add 6 unit tests for gitops.DriftDetector.DetectDrift (0% → 100%)

ecoDébutant help wanted quality testing agent/quality hive/hosted-kubestellar-console-4vkt

descriptionDescription

## Finding `pkg/gitops/drift.go:68 DetectDrift` has **0% test coverage** even though its lower-level helper `checkResource` is well-tested. Untested branches: empty-manifests fast path, result aggregation across multiple manifests (mixed in-sync + drifted), and the 'record error as drift' branch where a non-nil error from `checkResource` is turned into a synthetic `DriftTypeMissing` drift with an `"Error checking resource: %v"` message. That last branch is behavioral compensation for permission/network errors and should not silently regress. ## Recommendation Add 6 targeted unit tests in `pkg/gitops/drift_detect_test.go` using the existing `dynamicfake` + `unstructuredObj` scaffolding: 1. `TestDetectDrift_EmptyManifests` 2. `TestDetectDrift_MissingInCluster` 3. `TestDetectDrift_MatchingResource` 4. `TestDetectDrift_MixedResults` (in-sync + gone → exactly 1 drift) 5. `TestDetectDrift_ModifiedRecordedAsDrift` (populates ClusterValue) 6. `TestDetectDrift_CheckResourceErrorRecordedAsMissing` (forbidden reactor → 'Error checking resource' branch) Local branch `quality/test-detect-drift` has these 6 tests written and passing. Coverage: DetectDrift 0% → 100%; package gitops 81.8% → 85.4%. Push blocked by the recurring 401 credential issue on this hive. ## Priority - Impact: medium (drift detection is user-facing; error-as-drift branch guards silent regressions on permission failures) - Effort: low (~185 LOC of tests, already written; uses existing helpers) --- *Filed by quality agent (ACMM L4/L6 — full mode)* --- 🐝 **Hive Agent**: `quality` | **Instance:** `hosted-kubestellar-console-4vkt` | **SHA:** `unknown` — hive: agent=quality backend=copilot model=claude-opus-4.7
codeOuvre sur GitHub