mirror of
https://github.com/octoleo/restic.git
synced 2024-11-25 22:27:35 +00:00
Add helper function for Duration parsing
Tests in cmd_forget_test.go need the same convenience function that was implemented in snapshot_policy_test.go. Function parseDuration(...) was moved to testing.go and renamed to ParseDurationOrPanic(...).
This commit is contained in:
parent
667536cea4
commit
b7f03d01b8
@ -212,3 +212,14 @@ func TestParseHandle(s string, t BlobType) BlobHandle {
|
||||
func TestSetSnapshotID(t testing.TB, sn *Snapshot, id ID) {
|
||||
sn.id = &id
|
||||
}
|
||||
|
||||
// Convenience function that parses a duration from a string or panics if string is invalid.
|
||||
// The format is `6y5m234d37h`.
|
||||
func ParseDurationOrPanic(s string) Duration {
|
||||
d, err := ParseDuration(s)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return d
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user