[#292] pruning: grid: add all snapshots that do not match the regex to the rule's destroy list

Before this patch, multiple grids with disjoint regexes would result in
no snapshots being destroyed at all.

fixes #292
This commit is contained in:
Christian Schwarz
2020-08-29 17:29:08 +02:00
parent bcf6ff1c08
commit 3a4e841c73
3 changed files with 43 additions and 7 deletions
+22
View File
@@ -75,6 +75,10 @@ func TestPruneSnapshots(t *testing.T) {
},
}
reltime := func(secs int64) time.Time {
return time.Unix(secs, 0)
}
tcs := map[string]testCase{
"simple": {
inputs: inputs["s1"],
@@ -121,6 +125,24 @@ func TestPruneSnapshots(t *testing.T) {
},
expDestroy: map[string]bool{},
},
"multiple_grids_with_disjoint_regexes": {
inputs: []Snapshot{
stubSnap{"p1_a", false, reltime(4)},
stubSnap{"p2_a", false, reltime(5)},
stubSnap{"p1_b", false, reltime(14)},
stubSnap{"p2_b", false, reltime(15)},
stubSnap{"p1_c", false, reltime(29)},
stubSnap{"p2_c", false, reltime(30)},
},
rules: []KeepRule{
MustNewKeepGrid("^p1_", `1x10s | 1x10s`),
MustNewKeepGrid("^p2_", `1x10s | 1x10s`),
},
expDestroy: map[string]bool{
"p1_a": true,
"p2_a": true,
},
},
}
testTable(tcs, t)