Summary
Add and expand unit tests across three domains: controller event predicates (48 specs), runtime feature gate detection (38 specs), and cloudflared builder gap coverage (90 specs). Combined: 176 new specs.
CEL validation coverage (109 specs) split to #40.
Context
These three domains share similar characteristics: moderate complexity, limited scope per domain, and existing test infrastructure in some cases. Bundling them into one issue avoids issue sprawl while keeping work parallelizable within the issue.
Scope
Predicates (48 specs)
Test all 4 custom predicates across 4 event types (Create, Update, Delete, Generic):
| Predicate |
Key Behavior |
GenerationOrDeletionPredicate |
Passes on generation change or non-zero deletion timestamp |
CfgateAnnotationOrGenerationPredicate |
Passes on cfgate.io/* annotation change or generation change |
TunnelIDChangedPredicate |
Passes when .status.tunnelID changes |
GatewayCreateAnnotationFilter |
Passes on create if cfgate annotation present |
Also tests unexported helper cfgateAnnotationsChanged.
Requires controller-runtime event types and cfgate API types.
File: internal/controller/predicates_test.go (new)
Feature Detection (38 specs)
Test DetectFeatures() with mock discovery.DiscoveryInterface:
| Scenario |
Specs |
| All CRDs present |
4 |
| Individual CRD missing |
8 |
| Discovery error |
6 |
| Partial install |
8 |
| Upgrade scenarios |
6 |
| SupportedRouteKinds |
6 |
File: internal/controller/features/detection_test.go (new)
Builder Gap Coverage (90 specs)
Extend existing builder tests to cover untested functions:
| Function |
Current Coverage |
Gap |
SetCatchAll |
None |
4 specs |
ParseConfig |
None |
14 specs |
BuildConfigMap |
None |
10 specs |
BuildTokenSecret |
None |
10 specs |
getMetricsPort |
None |
6 specs |
NewTunnelConfig protocol |
Partial |
7 specs |
AddRule extended |
Partial |
4 specs |
Validate extended |
Partial |
6 specs |
Marshal round-trip |
Partial |
4 specs |
BuildOriginConfig annotations |
Partial |
25 specs |
Files: internal/cloudflared/configmap_test.go, internal/cloudflared/deployment_test.go (extend existing)
References
Acceptance Criteria
Summary
Add and expand unit tests across three domains: controller event predicates (48 specs), runtime feature gate detection (38 specs), and cloudflared builder gap coverage (90 specs). Combined: 176 new specs.
CEL validation coverage (109 specs) split to #40.
Context
These three domains share similar characteristics: moderate complexity, limited scope per domain, and existing test infrastructure in some cases. Bundling them into one issue avoids issue sprawl while keeping work parallelizable within the issue.
Scope
Predicates (48 specs)
Test all 4 custom predicates across 4 event types (Create, Update, Delete, Generic):
GenerationOrDeletionPredicateCfgateAnnotationOrGenerationPredicateTunnelIDChangedPredicate.status.tunnelIDchangesGatewayCreateAnnotationFilterAlso tests unexported helper
cfgateAnnotationsChanged.Requires controller-runtime event types and cfgate API types.
File:
internal/controller/predicates_test.go(new)Feature Detection (38 specs)
Test
DetectFeatures()with mockdiscovery.DiscoveryInterface:File:
internal/controller/features/detection_test.go(new)Builder Gap Coverage (90 specs)
Extend existing builder tests to cover untested functions:
SetCatchAllParseConfigBuildConfigMapBuildTokenSecretgetMetricsPortNewTunnelConfigprotocolAddRuleextendedValidateextendedMarshalround-tripBuildOriginConfigannotationsFiles:
internal/cloudflared/configmap_test.go,internal/cloudflared/deployment_test.go(extend existing)References
~/.atlas/integrator/analysis/cfgate/t1-support-layer-design-2026-03-13.md,t1-builders-validation-design-2026-03-13.mdAcceptance Criteria
go test ./internal/...