@@ -457,6 +457,48 @@ func TestConvertAndPresent_RoundTrip(t *testing.T) {
457457 Expect (* result .Metadata .JobName ).To (Equal (* originalReq .Metadata .JobName ))
458458}
459459
460+ // TestPresentAdapterStatus_FiltersInvalidConditionStatus verifies that conditions with
461+ // empty or invalid status values (legacy data) are excluded from GET responses.
462+ func TestPresentAdapterStatus_FiltersInvalidConditionStatus (t * testing.T ) {
463+ RegisterTestingT (t )
464+
465+ now := time .Now ()
466+ reason := "Healthy"
467+ message := "All good"
468+
469+ conditions := []api.AdapterCondition {
470+ // Valid — should be kept
471+ {Type : "Health" , Status : api .AdapterConditionTrue , Reason : & reason , Message : & message , LastTransitionTime : now },
472+ {Type : "Available" , Status : api .AdapterConditionFalse , LastTransitionTime : now },
473+ {Type : "Ready" , Status : api .AdapterConditionUnknown , LastTransitionTime : now },
474+
475+ // Invalid — should be filtered out (legacy data)
476+ {Type : "Applied" , Status : "" , LastTransitionTime : now },
477+ {Type : "Reconciled" , Status : "garbage" , LastTransitionTime : now },
478+ }
479+ conditionsJSON , _ := json .Marshal (conditions )
480+
481+ adapterStatus := & api.AdapterStatus {
482+ ResourceType : "Cluster" ,
483+ ResourceID : "cluster-legacy" ,
484+ Adapter : "test-adapter" ,
485+ ObservedGeneration : 1 ,
486+ Conditions : conditionsJSON ,
487+ Data : []byte ("{}" ),
488+ CreatedTime : now ,
489+ LastReportTime : now ,
490+ }
491+
492+ result , err := PresentAdapterStatus (adapterStatus )
493+ Expect (err ).To (BeNil ())
494+
495+ Expect (result .Conditions ).To (HaveLen (3 ))
496+ for _ , cond := range result .Conditions {
497+ Expect (cond .Type ).ToNot (Equal ("Applied" ))
498+ Expect (cond .Type ).ToNot (Equal ("Reconciled" ))
499+ }
500+ }
501+
460502// TestPresentAdapterStatus_MalformedConditions tests error handling for malformed Conditions JSON
461503func TestPresentAdapterStatus_MalformedConditions (t * testing.T ) {
462504 RegisterTestingT (t )
0 commit comments