diff --git a/internal/restic/testing.go b/internal/restic/testing.go index ebafdf651..9c21b81d1 100644 --- a/internal/restic/testing.go +++ b/internal/restic/testing.go @@ -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 +}