Unit testing for internal.Duration Unmarshal

closes #1926
This commit is contained in:
Cameron Sparr
2016-10-25 13:11:32 +01:00
parent 662db7a944
commit f729fa990d
2 changed files with 25 additions and 0 deletions

View File

@@ -36,6 +36,12 @@ type Duration struct {
func (d *Duration) UnmarshalTOML(b []byte) error {
var err error
// see if we can straight convert it
d.Duration, err = time.ParseDuration(string(b))
if err == nil {
return nil
}
// Parse string duration, ie, "1s"
if uq, err := strconv.Unquote(string(b)); err == nil && len(uq) > 0 {
d.Duration, err = time.ParseDuration(uq)