1
0
Fork 0
mirror of https://github.com/imjasonh/git-k8s synced 2026-07-18 15:05:45 +00:00

Improve test coverage from 10.3% to 42.7% with diffcover analysis

Apply the diffcover technique to map code snippets to features, identify
under-tested components, and add comprehensive tests for all reconciler
business logic. Key improvements:

- pkg/reconciler/internal: 26.7% → 100% (generic adapter fully tested)
- pkg/client: 5.6% → 71.8% (full CRUD for all 4 resource types)
- pkg/reconciler/repowatcher: 10.1% → 56.3% (ReconcileKind lifecycle)
- pkg/reconciler/push: 0% → 33.3% (failTransaction, updateBranches)
- pkg/reconciler/sync: 0% → 33.0% (findBranch, createPushTransaction)
- pkg/reconciler/resolver: 2.1% → 17.0% (merge transactions, manual intervention)

Includes COVERAGE_REPORT.md with full code-to-feature mapping showing
which tests cover which lines, following the diffcover methodology.

https://claude.ai/code/session_016Yeyfoocn7SN2HuMsxRD6f
This commit is contained in:
Claude 2026-03-04 19:49:59 +00:00
parent b544a42468
commit 01fcebed54
No known key found for this signature in database
8 changed files with 2064 additions and 0 deletions

View file

@ -2,6 +2,8 @@ package v1alpha1
import (
"testing"
"k8s.io/apimachinery/pkg/runtime"
)
func TestSetDefaults_GitRepository(t *testing.T) {
@ -67,3 +69,31 @@ func TestSetDefaults_GitPushTransaction(t *testing.T) {
})
}
}
func TestRegisterDefaults(t *testing.T) {
scheme := runtime.NewScheme()
// Register the types so the scheme knows about them.
if err := AddToScheme(scheme); err != nil {
t.Fatalf("AddToScheme() error = %v", err)
}
// Register defaults.
if err := RegisterDefaults(scheme); err != nil {
t.Fatalf("RegisterDefaults() error = %v", err)
}
// Verify GitRepository defaults are applied via scheme.
repo := &GitRepository{}
scheme.Default(repo)
if repo.Spec.DefaultBranch != "main" {
t.Errorf("DefaultBranch after scheme.Default = %q, want %q", repo.Spec.DefaultBranch, "main")
}
// Verify GitPushTransaction defaults are applied via scheme.
txn := &GitPushTransaction{}
scheme.Default(txn)
if txn.Status.Phase != TransactionPhasePending {
t.Errorf("Phase after scheme.Default = %q, want %q", txn.Status.Phase, TransactionPhasePending)
}
}