forked from TrueCloudLab/restic
forget: Add test with regular and "forever" opts
This commit is contained in:
parent
32e6a438be
commit
ba183c44c3
2 changed files with 200 additions and 4 deletions
|
@ -242,7 +242,7 @@ func TestApplyPolicy(t *testing.T) {
|
|||
{Last: -1}, // keep all
|
||||
{Last: -1, Hourly: -1}, // keep all (Last overrides Hourly)
|
||||
{Hourly: -1}, // keep all hourlies
|
||||
// {Daily: 3, Weekly: 2, Monthly: -1, Yearly: -1},
|
||||
{Daily: 3, Weekly: 2, Monthly: -1, Yearly: -1},
|
||||
}
|
||||
|
||||
for i, p := range tests {
|
||||
|
@ -255,10 +255,12 @@ func TestApplyPolicy(t *testing.T) {
|
|||
len(keep)+len(remove), len(testExpireSnapshots))
|
||||
}
|
||||
|
||||
if p.Last >= 0 && p.Hourly >= 0 && p.Daily >= 0 && p.Weekly >= 0 && p.Monthly >= 0 && p.Yearly >= 0 {
|
||||
if p.Sum() > 0 && len(keep) > p.Sum() {
|
||||
t.Errorf("not enough snapshots removed: policy allows %v snapshots to remain, but ended up with %v",
|
||||
p.Sum(), len(keep))
|
||||
}
|
||||
}
|
||||
|
||||
if len(keep) != len(reasons) {
|
||||
t.Errorf("got %d keep reasons for %d snapshots to keep, these must be equal", len(reasons), len(keep))
|
||||
|
|
194
internal/restic/testdata/policy_keep_snapshots_39
vendored
Normal file
194
internal/restic/testdata/policy_keep_snapshots_39
vendored
Normal file
|
@ -0,0 +1,194 @@
|
|||
{
|
||||
"keep": [
|
||||
{
|
||||
"time": "2016-01-18T12:02:03Z",
|
||||
"tree": null,
|
||||
"paths": null
|
||||
},
|
||||
{
|
||||
"time": "2016-01-12T21:08:03Z",
|
||||
"tree": null,
|
||||
"paths": null
|
||||
},
|
||||
{
|
||||
"time": "2016-01-09T21:02:03Z",
|
||||
"tree": null,
|
||||
"paths": null
|
||||
},
|
||||
{
|
||||
"time": "2015-11-22T10:20:30Z",
|
||||
"tree": null,
|
||||
"paths": null
|
||||
},
|
||||
{
|
||||
"time": "2015-10-22T10:20:30Z",
|
||||
"tree": null,
|
||||
"paths": null
|
||||
},
|
||||
{
|
||||
"time": "2015-09-22T10:20:30Z",
|
||||
"tree": null,
|
||||
"paths": null
|
||||
},
|
||||
{
|
||||
"time": "2015-08-22T10:20:30Z",
|
||||
"tree": null,
|
||||
"paths": null
|
||||
},
|
||||
{
|
||||
"time": "2014-11-22T10:20:30Z",
|
||||
"tree": null,
|
||||
"paths": null
|
||||
},
|
||||
{
|
||||
"time": "2014-10-22T10:20:30Z",
|
||||
"tree": null,
|
||||
"paths": null,
|
||||
"tags": [
|
||||
"foo"
|
||||
]
|
||||
},
|
||||
{
|
||||
"time": "2014-09-22T10:20:30Z",
|
||||
"tree": null,
|
||||
"paths": null
|
||||
},
|
||||
{
|
||||
"time": "2014-08-22T10:20:30Z",
|
||||
"tree": null,
|
||||
"paths": null
|
||||
}
|
||||
],
|
||||
"reasons": [
|
||||
{
|
||||
"snapshot": {
|
||||
"time": "2016-01-18T12:02:03Z",
|
||||
"tree": null,
|
||||
"paths": null
|
||||
},
|
||||
"matches": [
|
||||
"daily snapshot",
|
||||
"weekly snapshot",
|
||||
"monthly snapshot",
|
||||
"yearly snapshot"
|
||||
],
|
||||
"counters": {"Daily": 2, "Weekly": 1, "Monthly": -1, "Yearly": -1}
|
||||
},
|
||||
{
|
||||
"snapshot": {
|
||||
"time": "2016-01-12T21:08:03Z",
|
||||
"tree": null,
|
||||
"paths": null
|
||||
},
|
||||
"matches": [
|
||||
"daily snapshot",
|
||||
"weekly snapshot"
|
||||
],
|
||||
"counters": {"Daily": 1, "Monthly": -1, "Yearly": -1}
|
||||
},
|
||||
{
|
||||
"snapshot": {
|
||||
"time": "2016-01-09T21:02:03Z",
|
||||
"tree": null,
|
||||
"paths": null
|
||||
},
|
||||
"matches": [
|
||||
"daily snapshot"
|
||||
],
|
||||
"counters": {"Monthly": -1, "Yearly": -1}
|
||||
},
|
||||
{
|
||||
"snapshot": {
|
||||
"time": "2015-11-22T10:20:30Z",
|
||||
"tree": null,
|
||||
"paths": null
|
||||
},
|
||||
"matches": [
|
||||
"monthly snapshot",
|
||||
"yearly snapshot"
|
||||
],
|
||||
"counters": {"Monthly": -1, "Yearly": -1}
|
||||
},
|
||||
{
|
||||
"snapshot": {
|
||||
"time": "2015-10-22T10:20:30Z",
|
||||
"tree": null,
|
||||
"paths": null
|
||||
},
|
||||
"matches": [
|
||||
"monthly snapshot"
|
||||
],
|
||||
"counters": {"Monthly": -1, "Yearly": -1}
|
||||
},
|
||||
{
|
||||
"snapshot": {
|
||||
"time": "2015-09-22T10:20:30Z",
|
||||
"tree": null,
|
||||
"paths": null
|
||||
},
|
||||
"matches": [
|
||||
"monthly snapshot"
|
||||
],
|
||||
"counters": {"Monthly": -1, "Yearly": -1}
|
||||
},
|
||||
{
|
||||
"snapshot": {
|
||||
"time": "2015-08-22T10:20:30Z",
|
||||
"tree": null,
|
||||
"paths": null
|
||||
},
|
||||
"matches": [
|
||||
"monthly snapshot"
|
||||
],
|
||||
"counters": {"Monthly": -1, "Yearly": -1}
|
||||
},
|
||||
{
|
||||
"snapshot": {
|
||||
"time": "2014-11-22T10:20:30Z",
|
||||
"tree": null,
|
||||
"paths": null
|
||||
},
|
||||
"matches": [
|
||||
"monthly snapshot",
|
||||
"yearly snapshot"
|
||||
],
|
||||
"counters": {"Monthly": -1, "Yearly": -1}
|
||||
},
|
||||
{
|
||||
"snapshot": {
|
||||
"time": "2014-10-22T10:20:30Z",
|
||||
"tree": null,
|
||||
"paths": null,
|
||||
"tags": [
|
||||
"foo"
|
||||
]
|
||||
},
|
||||
"matches": [
|
||||
"monthly snapshot"
|
||||
],
|
||||
"counters": {"Monthly": -1, "Yearly": -1}
|
||||
},
|
||||
{
|
||||
"snapshot": {
|
||||
"time": "2014-09-22T10:20:30Z",
|
||||
"tree": null,
|
||||
"paths": null
|
||||
},
|
||||
"matches": [
|
||||
"monthly snapshot"
|
||||
],
|
||||
"counters": {"Monthly": -1, "Yearly": -1}
|
||||
},
|
||||
{
|
||||
"snapshot": {
|
||||
"time": "2014-08-22T10:20:30Z",
|
||||
"tree": null,
|
||||
"paths": null
|
||||
},
|
||||
"matches": [
|
||||
"monthly snapshot"
|
||||
],
|
||||
"counters": {"Monthly": -1, "Yearly": -1}
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in a new issue