@@ -1750,6 +1750,57 @@ func TestSyncOptionPruneFalse(t *testing.T) {
17501750 Expect (ResourceSyncStatusIs ("Pod" , "pod-1" , SyncStatusCodeOutOfSync ))
17511751}
17521752
1753+ // make sure that if we deleted a resource from the app, it is not pruned if the app has the sync option Prune=false
1754+ func TestSyncOptionSyncOptionPruneFalse (t * testing.T ) {
1755+ Given (t ).
1756+ Path ("two-nice-pods" ).
1757+ When ().
1758+ CreateApp ().
1759+ PatchApp (`[{
1760+ "op": "add",
1761+ "path": "/spec/syncPolicy",
1762+ "value": { "syncOptions": ["Prune=false"] }
1763+ }]` ).
1764+ Sync ().
1765+ Then ().
1766+ Expect (OperationPhaseIs (OperationSucceeded )).
1767+ Expect (SyncStatusIs (SyncStatusCodeSynced )).
1768+ When ().
1769+ DeleteFile ("pod-1.yaml" ).
1770+ Refresh (RefreshTypeHard ).
1771+ IgnoreErrors ().
1772+ Sync ().
1773+ Then ().
1774+ Expect (OperationPhaseIs (OperationSucceeded )).
1775+ Expect (SyncStatusIs (SyncStatusCodeOutOfSync )).
1776+ Expect (ResourceSyncStatusIs ("Pod" , "pod-1" , SyncStatusCodeOutOfSync ))
1777+
1778+ // Also check that another setting on a ressource level doesn't override that
1779+ Given (t ).
1780+ Path ("two-nice-pods" ).
1781+ When ().
1782+ CreateApp ().
1783+ PatchApp (`[{
1784+ "op": "add",
1785+ "path": "/spec/syncPolicy",
1786+ "value": { "syncOptions": ["Prune=false"] }
1787+ }]` ).
1788+ PatchFile ("pod-1.yaml" , `[{"op": "add", "path": "/metadata/annotations", "value": {"argocd.argoproj.io/sync-options": "Prune=true"}}]` ).
1789+ Sync ().
1790+ Then ().
1791+ Expect (OperationPhaseIs (OperationSucceeded )).
1792+ Expect (SyncStatusIs (SyncStatusCodeSynced )).
1793+ When ().
1794+ DeleteFile ("pod-1.yaml" ).
1795+ Refresh (RefreshTypeHard ).
1796+ IgnoreErrors ().
1797+ Sync ().
1798+ Then ().
1799+ Expect (OperationPhaseIs (OperationSucceeded )).
1800+ Expect (SyncStatusIs (SyncStatusCodeOutOfSync )).
1801+ Expect (ResourceSyncStatusIs ("Pod" , "pod-1" , SyncStatusCodeOutOfSync ))
1802+ }
1803+
17531804// make sure that if we have an invalid manifest, we can add it if we disable validation, we get a server error rather than a client error
17541805func TestSyncOptionValidateFalse (t * testing.T ) {
17551806 Given (t ).
0 commit comments