config: add Duration test coverage and fix error wrapping

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I5c08e63297f90acdedd9744de904c36b6a6a6964
This commit is contained in:
raf 2026-03-05 23:49:11 +03:00
commit 9f264fbef1
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
4 changed files with 54 additions and 44 deletions

View file

@ -21,7 +21,7 @@ func (d *Duration) UnmarshalYAML(value *yaml.Node) error {
// Try decoding as a raw int64 (nanoseconds) as fallback.
var ns int64
if err2 := value.Decode(&ns); err2 != nil {
return fmt.Errorf("cannot unmarshal duration: %w", err)
return fmt.Errorf("cannot unmarshal duration (tried string: %v): %w", err, err2)
}
d.Duration = time.Duration(ns)
return nil