@@ -1296,6 +1296,7 @@ func TestSetBindingStatus(t *testing.T) {
12961296 tests := map [string ]struct {
12971297 works map [string ]* fleetv1beta1.Work
12981298 applyStrategy * fleetv1beta1.ApplyStrategy
1299+ workDeleted bool
12991300 maxFailedResourcePlacementLimit * int
13001301 wantFailedResourcePlacements []fleetv1beta1.FailedResourcePlacement
13011302 maxDriftedResourcePlacementLimit * int
@@ -1522,6 +1523,7 @@ func TestSetBindingStatus(t *testing.T) {
15221523 },
15231524 },
15241525 },
1526+
15251527 "One work has one not available and one work has one not applied (exceed the maxFailedResourcePlacementLimit)" : {
15261528 works : map [string ]* fleetv1beta1.Work {
15271529 "work1" : {
@@ -2366,6 +2368,148 @@ func TestSetBindingStatus(t *testing.T) {
23662368 },
23672369 },
23682370 },
2371+ "Some work has been applied and some has been deleted" : {
2372+ works : map [string ]* fleetv1beta1.Work {
2373+ "work1" : {
2374+ Status : fleetv1beta1.WorkStatus {
2375+ ManifestConditions : []fleetv1beta1.ManifestCondition {
2376+ {
2377+ Identifier : fleetv1beta1.WorkResourceIdentifier {
2378+ Ordinal : 0 ,
2379+ Group : "" ,
2380+ Version : "v1" ,
2381+ Kind : "ConfigMap" ,
2382+ Name : "config-name" ,
2383+ Namespace : "config-namespace" ,
2384+ },
2385+ Conditions : []metav1.Condition {
2386+ {
2387+ Type : fleetv1beta1 .WorkConditionTypeApplied ,
2388+ Status : metav1 .ConditionTrue ,
2389+ },
2390+ {
2391+ Type : fleetv1beta1 .WorkConditionTypeAvailable ,
2392+ Status : metav1 .ConditionFalse ,
2393+ },
2394+ },
2395+ },
2396+ {
2397+ Identifier : fleetv1beta1.WorkResourceIdentifier {
2398+ Ordinal : 1 ,
2399+ Group : "" ,
2400+ Version : "v1" ,
2401+ Kind : "Service" ,
2402+ Name : "svc-name" ,
2403+ Namespace : "svc-namespace" ,
2404+ },
2405+ Conditions : []metav1.Condition {
2406+ {
2407+ Type : fleetv1beta1 .WorkConditionTypeApplied ,
2408+ Status : metav1 .ConditionTrue ,
2409+ },
2410+ {
2411+ Type : fleetv1beta1 .WorkConditionTypeAvailable ,
2412+ Status : metav1 .ConditionTrue ,
2413+ },
2414+ },
2415+ },
2416+ },
2417+ Conditions : []metav1.Condition {
2418+ {
2419+ Type : fleetv1beta1 .WorkConditionTypeApplied ,
2420+ Status : metav1 .ConditionTrue ,
2421+ },
2422+ {
2423+ Type : fleetv1beta1 .WorkConditionTypeAvailable ,
2424+ Status : metav1 .ConditionFalse ,
2425+ },
2426+ },
2427+ },
2428+ },
2429+ "work2" : {
2430+ Status : fleetv1beta1.WorkStatus {
2431+ ManifestConditions : []fleetv1beta1.ManifestCondition {
2432+ {
2433+ Identifier : fleetv1beta1.WorkResourceIdentifier {
2434+ Ordinal : 0 ,
2435+ Group : "" ,
2436+ Version : "v1" ,
2437+ Kind : "ConfigMap" ,
2438+ Name : "config-name-1" ,
2439+ Namespace : "config-namespace" ,
2440+ },
2441+ Conditions : []metav1.Condition {
2442+ {
2443+ Type : fleetv1beta1 .WorkConditionTypeApplied ,
2444+ Status : metav1 .ConditionTrue ,
2445+ },
2446+ {
2447+ Type : fleetv1beta1 .WorkConditionTypeAvailable ,
2448+ Status : metav1 .ConditionTrue ,
2449+ },
2450+ },
2451+ },
2452+ {
2453+ Identifier : fleetv1beta1.WorkResourceIdentifier {
2454+ Ordinal : 1 ,
2455+ Group : "" ,
2456+ Version : "v1" ,
2457+ Kind : "Service" ,
2458+ Name : "svc-name-1" ,
2459+ Namespace : "svc-namespace" ,
2460+ },
2461+ Conditions : []metav1.Condition {
2462+ {
2463+ Type : fleetv1beta1 .WorkConditionTypeApplied ,
2464+ Status : metav1 .ConditionFalse ,
2465+ },
2466+ },
2467+ },
2468+ },
2469+ Conditions : []metav1.Condition {
2470+ {
2471+ Type : fleetv1beta1 .WorkConditionTypeApplied ,
2472+ Status : metav1 .ConditionFalse ,
2473+ },
2474+ {
2475+ Type : fleetv1beta1 .WorkConditionTypeAvailable ,
2476+ Status : metav1 .ConditionFalse ,
2477+ },
2478+ },
2479+ },
2480+ },
2481+ // "work3" was deleted
2482+ },
2483+ workDeleted : true ,
2484+ wantFailedResourcePlacements : []fleetv1beta1.FailedResourcePlacement {
2485+ {
2486+ ResourceIdentifier : fleetv1beta1.ResourceIdentifier {
2487+ Group : "" ,
2488+ Version : "v1" ,
2489+ Kind : "ConfigMap" ,
2490+ Name : "config-name" ,
2491+ Namespace : "config-namespace" ,
2492+ },
2493+ Condition : metav1.Condition {
2494+ Type : fleetv1beta1 .WorkConditionTypeAvailable ,
2495+ Status : metav1 .ConditionFalse ,
2496+ },
2497+ },
2498+ {
2499+ ResourceIdentifier : fleetv1beta1.ResourceIdentifier {
2500+ Group : "" ,
2501+ Version : "v1" ,
2502+ Kind : "Service" ,
2503+ Name : "svc-name-1" ,
2504+ Namespace : "svc-namespace" ,
2505+ },
2506+ Condition : metav1.Condition {
2507+ Type : fleetv1beta1 .WorkConditionTypeApplied ,
2508+ Status : metav1 .ConditionFalse ,
2509+ },
2510+ },
2511+ },
2512+ },
23692513 }
23702514
23712515 originalMaxFailedResourcePlacementLimit := maxFailedResourcePlacementLimit
@@ -2401,7 +2545,7 @@ func TestSetBindingStatus(t *testing.T) {
24012545 ApplyStrategy : tt .applyStrategy ,
24022546 },
24032547 }
2404- setBindingStatus (false , tt .works , binding )
2548+ setBindingStatus (tt . workDeleted , tt .works , binding )
24052549 got := binding .Status .FailedPlacements
24062550 // setBindingStatus is using map to populate the placements.
24072551 // There is no default order in traversing the map.
0 commit comments