mirror of
https://github.com/octoleo/restic.git
synced 2024-11-24 21:57:41 +00:00
forget: simplify test
This commit is contained in:
parent
50b43fbac0
commit
3f919f2371
@ -42,50 +42,49 @@ func TestForgetOptionValues(t *testing.T) {
|
|||||||
const negDurationValErrorMsg = "Fatal: durations containing negative values are not allowed for --keep-within*"
|
const negDurationValErrorMsg = "Fatal: durations containing negative values are not allowed for --keep-within*"
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
input ForgetOptions
|
input ForgetOptions
|
||||||
expectsError bool
|
|
||||||
errorMsg string
|
errorMsg string
|
||||||
}{
|
}{
|
||||||
{ForgetOptions{Last: 1}, false, ""},
|
{ForgetOptions{Last: 1}, ""},
|
||||||
{ForgetOptions{Hourly: 1}, false, ""},
|
{ForgetOptions{Hourly: 1}, ""},
|
||||||
{ForgetOptions{Daily: 1}, false, ""},
|
{ForgetOptions{Daily: 1}, ""},
|
||||||
{ForgetOptions{Weekly: 1}, false, ""},
|
{ForgetOptions{Weekly: 1}, ""},
|
||||||
{ForgetOptions{Monthly: 1}, false, ""},
|
{ForgetOptions{Monthly: 1}, ""},
|
||||||
{ForgetOptions{Yearly: 1}, false, ""},
|
{ForgetOptions{Yearly: 1}, ""},
|
||||||
{ForgetOptions{Last: 0}, false, ""},
|
{ForgetOptions{Last: 0}, ""},
|
||||||
{ForgetOptions{Hourly: 0}, false, ""},
|
{ForgetOptions{Hourly: 0}, ""},
|
||||||
{ForgetOptions{Daily: 0}, false, ""},
|
{ForgetOptions{Daily: 0}, ""},
|
||||||
{ForgetOptions{Weekly: 0}, false, ""},
|
{ForgetOptions{Weekly: 0}, ""},
|
||||||
{ForgetOptions{Monthly: 0}, false, ""},
|
{ForgetOptions{Monthly: 0}, ""},
|
||||||
{ForgetOptions{Yearly: 0}, false, ""},
|
{ForgetOptions{Yearly: 0}, ""},
|
||||||
{ForgetOptions{Last: -1}, false, ""},
|
{ForgetOptions{Last: -1}, ""},
|
||||||
{ForgetOptions{Hourly: -1}, false, ""},
|
{ForgetOptions{Hourly: -1}, ""},
|
||||||
{ForgetOptions{Daily: -1}, false, ""},
|
{ForgetOptions{Daily: -1}, ""},
|
||||||
{ForgetOptions{Weekly: -1}, false, ""},
|
{ForgetOptions{Weekly: -1}, ""},
|
||||||
{ForgetOptions{Monthly: -1}, false, ""},
|
{ForgetOptions{Monthly: -1}, ""},
|
||||||
{ForgetOptions{Yearly: -1}, false, ""},
|
{ForgetOptions{Yearly: -1}, ""},
|
||||||
{ForgetOptions{Last: -2}, true, negValErrorMsg},
|
{ForgetOptions{Last: -2}, negValErrorMsg},
|
||||||
{ForgetOptions{Hourly: -2}, true, negValErrorMsg},
|
{ForgetOptions{Hourly: -2}, negValErrorMsg},
|
||||||
{ForgetOptions{Daily: -2}, true, negValErrorMsg},
|
{ForgetOptions{Daily: -2}, negValErrorMsg},
|
||||||
{ForgetOptions{Weekly: -2}, true, negValErrorMsg},
|
{ForgetOptions{Weekly: -2}, negValErrorMsg},
|
||||||
{ForgetOptions{Monthly: -2}, true, negValErrorMsg},
|
{ForgetOptions{Monthly: -2}, negValErrorMsg},
|
||||||
{ForgetOptions{Yearly: -2}, true, negValErrorMsg},
|
{ForgetOptions{Yearly: -2}, negValErrorMsg},
|
||||||
{ForgetOptions{Within: restic.ParseDurationOrPanic("1y2m3d3h")}, false, ""},
|
{ForgetOptions{Within: restic.ParseDurationOrPanic("1y2m3d3h")}, ""},
|
||||||
{ForgetOptions{WithinHourly: restic.ParseDurationOrPanic("1y2m3d3h")}, false, ""},
|
{ForgetOptions{WithinHourly: restic.ParseDurationOrPanic("1y2m3d3h")}, ""},
|
||||||
{ForgetOptions{WithinDaily: restic.ParseDurationOrPanic("1y2m3d3h")}, false, ""},
|
{ForgetOptions{WithinDaily: restic.ParseDurationOrPanic("1y2m3d3h")}, ""},
|
||||||
{ForgetOptions{WithinWeekly: restic.ParseDurationOrPanic("1y2m3d3h")}, false, ""},
|
{ForgetOptions{WithinWeekly: restic.ParseDurationOrPanic("1y2m3d3h")}, ""},
|
||||||
{ForgetOptions{WithinMonthly: restic.ParseDurationOrPanic("2y4m6d8h")}, false, ""},
|
{ForgetOptions{WithinMonthly: restic.ParseDurationOrPanic("2y4m6d8h")}, ""},
|
||||||
{ForgetOptions{WithinYearly: restic.ParseDurationOrPanic("2y4m6d8h")}, false, ""},
|
{ForgetOptions{WithinYearly: restic.ParseDurationOrPanic("2y4m6d8h")}, ""},
|
||||||
{ForgetOptions{Within: restic.ParseDurationOrPanic("-1y2m3d3h")}, true, negDurationValErrorMsg},
|
{ForgetOptions{Within: restic.ParseDurationOrPanic("-1y2m3d3h")}, negDurationValErrorMsg},
|
||||||
{ForgetOptions{WithinHourly: restic.ParseDurationOrPanic("1y-2m3d3h")}, true, negDurationValErrorMsg},
|
{ForgetOptions{WithinHourly: restic.ParseDurationOrPanic("1y-2m3d3h")}, negDurationValErrorMsg},
|
||||||
{ForgetOptions{WithinDaily: restic.ParseDurationOrPanic("1y2m-3d3h")}, true, negDurationValErrorMsg},
|
{ForgetOptions{WithinDaily: restic.ParseDurationOrPanic("1y2m-3d3h")}, negDurationValErrorMsg},
|
||||||
{ForgetOptions{WithinWeekly: restic.ParseDurationOrPanic("1y2m3d-3h")}, true, negDurationValErrorMsg},
|
{ForgetOptions{WithinWeekly: restic.ParseDurationOrPanic("1y2m3d-3h")}, negDurationValErrorMsg},
|
||||||
{ForgetOptions{WithinMonthly: restic.ParseDurationOrPanic("-2y4m6d8h")}, true, negDurationValErrorMsg},
|
{ForgetOptions{WithinMonthly: restic.ParseDurationOrPanic("-2y4m6d8h")}, negDurationValErrorMsg},
|
||||||
{ForgetOptions{WithinYearly: restic.ParseDurationOrPanic("2y-4m6d8h")}, true, negDurationValErrorMsg},
|
{ForgetOptions{WithinYearly: restic.ParseDurationOrPanic("2y-4m6d8h")}, negDurationValErrorMsg},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, testCase := range testCases {
|
for _, testCase := range testCases {
|
||||||
err := verifyForgetOptions(&testCase.input)
|
err := verifyForgetOptions(&testCase.input)
|
||||||
if testCase.expectsError {
|
if testCase.errorMsg != "" {
|
||||||
rtest.Assert(t, err != nil, "should have returned error for input %+v", testCase.input)
|
rtest.Assert(t, err != nil, "should have returned error for input %+v", testCase.input)
|
||||||
rtest.Equals(t, testCase.errorMsg, err.Error())
|
rtest.Equals(t, testCase.errorMsg, err.Error())
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user