@@ -22,6 +22,13 @@ func mockBcp(name string, daysAgo int, baseTime time.Time, status defs.Status) b
2222 }
2323}
2424
25+ // mockTypedBcp is a helper to generate fake backups with a specific Type.
26+ func mockTypedBcp (name string , daysAgo int , baseTime time.Time , status defs.Status , bcpType defs.BackupType ) backup.BackupMeta {
27+ bcp := mockBcp (name , daysAgo , baseTime , status )
28+ bcp .Type = bcpType
29+ return bcp
30+ }
31+
2532func TestEvaluate (t * testing.T ) {
2633 // Define a few specific dates we want to test against
2734 standardDate := time .Date (2026 , time .March , 26 , 12 , 0 , 0 , 0 , time .UTC ) // A normal Thursday
@@ -165,6 +172,27 @@ func TestEvaluate(t *testing.T) {
165172 expectedKept : []string {"bcp-error-recent" },
166173 expectedPurged : []string {"bcp-error-old" },
167174 },
175+ {
176+ name : "Type-Aware Bucketing - Keeps both Physical and Logical for the same week" ,
177+ cfg : config.LifecycleConf {
178+ Enabled : true ,
179+ Strategy : "rolling" ,
180+ DailyRetention : 0 , // Disable daily to force Weekly evaluation
181+ WeeklyRetention : 2 ,
182+ },
183+ mockNow : standardDate ,
184+ backups : []backup.BackupMeta {
185+ // Week 1 Bucket (7-13 days ago)
186+ mockTypedBcp ("phys-newer" , 9 , standardDate , defs .StatusDone , defs .PhysicalBackup ),
187+ mockTypedBcp ("phys-older" , 12 , standardDate , defs .StatusDone , defs .PhysicalBackup ), // Loses to phys-newer
188+
189+ // Same Week 1 Bucket, but Logical
190+ mockTypedBcp ("logical-only" , 11 , standardDate , defs .StatusDone , defs .LogicalBackup ), // Wins its own logical bucket
191+ },
192+ dryRun : false ,
193+ expectedKept : []string {"phys-newer" , "logical-only" },
194+ expectedPurged : []string {"phys-older" },
195+ },
168196 }
169197
170198 for _ , tt := range tests {
0 commit comments