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
+39
View File
@@ -0,0 +1,39 @@
package pruning
import (
"testing"
)
func TestNewKeepNotReplicated(t *testing.T) {
inputs := map[string][]Snapshot{
"s1": []Snapshot{
stubSnap{name: "1", replicated: true},
stubSnap{name: "2", replicated: false},
stubSnap{name: "3", replicated: true},
},
"s2": []Snapshot{},
}
tcs := map[string]testCase{
"destroysOnlyReplicated": {
inputs: inputs["s1"],
rules: []KeepRule{
NewKeepNotReplicated(),
},
expDestroy: map[string]bool{
"1": true, "3": true,
},
},
"empty": {
inputs: inputs["s2"],
rules: []KeepRule{
NewKeepNotReplicated(),
},
expDestroy: map[string]bool{},
},
}
testTable(tcs, t)
}