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
1 changed files with 11 additions and 0 deletions
|
@ -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 a new issue