@@ -62,6 +62,7 @@ func makeAD(name, image string, port int32, minReplicas int32) *agentraxv1alpha1
6262
6363// ── desiredDeployment ─────────────────────────────────────────────────────────
6464
65+ // TestDesiredDeployment_Image verifies that the desired Deployment container image matches spec.image.
6566func TestDesiredDeployment_Image (t * testing.T ) {
6667 r := & AgentDeploymentReconciler {}
6768 ad := makeAD ("my-agent" , "registry.io/agent:v1" , 8080 , 1 )
@@ -72,6 +73,7 @@ func TestDesiredDeployment_Image(t *testing.T) {
7273 }
7374}
7475
76+ // TestDesiredDeployment_Port verifies container port configuration and default fallback.
7577func TestDesiredDeployment_Port (t * testing.T ) {
7678 tests := []struct {
7779 name string
@@ -94,6 +96,7 @@ func TestDesiredDeployment_Port(t *testing.T) {
9496 }
9597}
9698
99+ // TestDesiredDeployment_Replicas verifies that desired Deployment replicas match spec.replicas.min.
97100func TestDesiredDeployment_Replicas (t * testing.T ) {
98101 r := & AgentDeploymentReconciler {}
99102 ad := makeAD (testDefaultAgent , testDefaultImage , 8080 , 3 )
@@ -104,6 +107,7 @@ func TestDesiredDeployment_Replicas(t *testing.T) {
104107 }
105108}
106109
110+ // TestDesiredDeployment_EnvAndArgs verifies propagation of environment variables and container arguments.
107111func TestDesiredDeployment_EnvAndArgs (t * testing.T ) {
108112 r := & AgentDeploymentReconciler {}
109113 ad := makeAD (testDefaultAgent , testDefaultImage , 8080 , 1 )
@@ -121,6 +125,7 @@ func TestDesiredDeployment_EnvAndArgs(t *testing.T) {
121125 }
122126}
123127
128+ // TestDesiredDeployment_Resources verifies container CPU and Memory resource requests/limits propagation.
124129func TestDesiredDeployment_Resources (t * testing.T ) {
125130 r := & AgentDeploymentReconciler {}
126131 ad := makeAD (testDefaultAgent , testDefaultImage , 8080 , 1 )
@@ -153,6 +158,7 @@ func TestDesiredDeployment_Resources(t *testing.T) {
153158 }
154159}
155160
161+ // TestDesiredDeployment_Labels verifies required standard labels on Deployment and Pod template.
156162func TestDesiredDeployment_Labels (t * testing.T ) {
157163 r := & AgentDeploymentReconciler {}
158164 ad := makeAD (testAgentName , testDefaultImage , 8080 , 1 )
@@ -173,6 +179,7 @@ func TestDesiredDeployment_Labels(t *testing.T) {
173179 }
174180}
175181
182+ // TestDesiredDeployment_SelectorMatchesPodLabels verifies Deployment selector matches Pod template labels.
176183func TestDesiredDeployment_SelectorMatchesPodLabels (t * testing.T ) {
177184 r := & AgentDeploymentReconciler {}
178185 ad := makeAD (testDefaultAgent , testDefaultImage , 8080 , 1 )
@@ -187,6 +194,7 @@ func TestDesiredDeployment_SelectorMatchesPodLabels(t *testing.T) {
187194
188195// ── desiredService ────────────────────────────────────────────────────────────
189196
197+ // TestDesiredService_Port verifies Service port configuration and default fallback.
190198func TestDesiredService_Port (t * testing.T ) {
191199 tests := []struct {
192200 name string
@@ -208,6 +216,7 @@ func TestDesiredService_Port(t *testing.T) {
208216 }
209217}
210218
219+ // TestDesiredService_Selector verifies Service selector targets the agent pod label.
211220func TestDesiredService_Selector (t * testing.T ) {
212221 r := & AgentDeploymentReconciler {}
213222 ad := makeAD (testAgentName , testDefaultImage , 8080 , 1 )
@@ -218,6 +227,7 @@ func TestDesiredService_Selector(t *testing.T) {
218227 }
219228}
220229
230+ // TestDesiredService_ClusterIPType verifies that the created Service is of type ClusterIP.
221231func TestDesiredService_ClusterIPType (t * testing.T ) {
222232 r := & AgentDeploymentReconciler {}
223233 ad := makeAD (testDefaultAgent , testDefaultImage , 8080 , 1 )
@@ -230,6 +240,7 @@ func TestDesiredService_ClusterIPType(t *testing.T) {
230240
231241// ── agentLabels ───────────────────────────────────────────────────────────────
232242
243+ // TestAgentLabels verifies standard label generation for an AgentDeployment.
233244func TestAgentLabels (t * testing.T ) {
234245 ad := & agentraxv1alpha1.AgentDeployment {
235246 ObjectMeta : metav1.ObjectMeta {Name : "foo" },
@@ -251,6 +262,7 @@ func TestAgentLabels(t *testing.T) {
251262
252263// ── condition helpers ─────────────────────────────────────────────────────────
253264
265+ // TestSetAndGetCondition verifies setting and reading status conditions on AgentDeployment.
254266func TestSetAndGetCondition (t * testing.T ) {
255267 ad := & agentraxv1alpha1.AgentDeployment {}
256268
@@ -268,6 +280,7 @@ func TestSetAndGetCondition(t *testing.T) {
268280 }
269281}
270282
283+ // TestSetCondition_Overwrite verifies that updating an existing condition updates in-place without duplicates.
271284func TestSetCondition_Overwrite (t * testing.T ) {
272285 ad := & agentraxv1alpha1.AgentDeployment {}
273286
@@ -284,6 +297,7 @@ func TestSetCondition_Overwrite(t *testing.T) {
284297 }
285298}
286299
300+ // TestRemoveCondition verifies condition removal from the status condition slice.
287301func TestRemoveCondition (t * testing.T ) {
288302 ad := & agentraxv1alpha1.AgentDeployment {}
289303
@@ -300,6 +314,7 @@ func TestRemoveCondition(t *testing.T) {
300314 }
301315}
302316
317+ // TestRemoveCondition_NonExistent verifies that removing a non-existent condition is a safe no-op.
303318func TestRemoveCondition_NonExistent (t * testing.T ) {
304319 ad := & agentraxv1alpha1.AgentDeployment {}
305320 // Should be a no-op, not panic.
@@ -309,6 +324,7 @@ func TestRemoveCondition_NonExistent(t *testing.T) {
309324 }
310325}
311326
327+ // TestGetCondition_Absent verifies that querying an un-set condition returns nil.
312328func TestGetCondition_Absent (t * testing.T ) {
313329 ad := & agentraxv1alpha1.AgentDeployment {}
314330 c := GetCondition (ad , agentraxv1alpha1 .ConditionReady )
@@ -319,6 +335,7 @@ func TestGetCondition_Absent(t *testing.T) {
319335
320336// ── desiredServiceMonitor ─────────────────────────────────────────────────────
321337
338+ // TestDesiredServiceMonitor_Endpoint verifies ServiceMonitor metrics endpoint configuration.
322339func TestDesiredServiceMonitor_Endpoint (t * testing.T ) {
323340 r := & AgentDeploymentReconciler {}
324341 ad := makeAD (testDefaultAgent , testDefaultImage , 8080 , 1 )
@@ -336,6 +353,7 @@ func TestDesiredServiceMonitor_Endpoint(t *testing.T) {
336353 }
337354}
338355
356+ // TestDesiredServiceMonitor_SelectorMatchesLabels verifies ServiceMonitor selector matches agent labels.
339357func TestDesiredServiceMonitor_SelectorMatchesLabels (t * testing.T ) {
340358 r := & AgentDeploymentReconciler {}
341359 ad := makeAD (testAgentName , testDefaultImage , 8080 , 1 )
0 commit comments