pruning: fix tests + implement 'not_replicated' and 'keep_regex' keep rule

tests expected that a KeepRule returns a *keep* list whereas it
actually returns a *destroy* list.
This commit is contained in:
Christian Schwarz
2018-08-30 11:44:43 +02:00
parent a2aa8e7bd7
commit d684302864
9 changed files with 134 additions and 43 deletions
+3 -3
View File
@@ -16,10 +16,10 @@ func NewKeepLastN(n int) (*KeepLastN, error) {
return &KeepLastN{n}, nil
}
func (k KeepLastN) KeepRule(snaps []Snapshot) []Snapshot {
func (k KeepLastN) KeepRule(snaps []Snapshot) (destroyList []Snapshot) {
if k.n > len(snaps) {
return snaps
return []Snapshot{}
}
res := shallowCopySnapList(snaps)
@@ -28,5 +28,5 @@ func (k KeepLastN) KeepRule(snaps []Snapshot) []Snapshot {
return res[i].Date().After(res[j].Date())
})
return res[:k.n]
return res[k.n:]
}