}
// Mimic error message returned by ParseDuration for a number
// without units.
- return fmt.Errorf("missing unit in duration %s", data)
+ return fmt.Errorf("missing unit in duration %q", data)
}
// MarshalJSON implements json.Marshaler.
D Duration
}
err := json.Unmarshal([]byte(`{"D":1.234}`), &d)
- c.Check(err, check.ErrorMatches, `missing unit in duration 1.234`)
+ c.Check(err, check.ErrorMatches, `.*missing unit in duration "?1\.234"?`)
err = json.Unmarshal([]byte(`{"D":"1.234"}`), &d)
- c.Check(err, check.ErrorMatches, `.*missing unit in duration 1.234`)
+ c.Check(err, check.ErrorMatches, `.*missing unit in duration "?1\.234"?`)
err = json.Unmarshal([]byte(`{"D":"1"}`), &d)
- c.Check(err, check.ErrorMatches, `.*missing unit in duration 1`)
+ c.Check(err, check.ErrorMatches, `.*missing unit in duration "?1"?`)
err = json.Unmarshal([]byte(`{"D":"foobar"}`), &d)
- c.Check(err, check.ErrorMatches, `.*invalid duration foobar`)
+ c.Check(err, check.ErrorMatches, `.*invalid duration "foobar"`)
err = json.Unmarshal([]byte(`{"D":"60s"}`), &d)
c.Check(err, check.IsNil)
c.Check(d.D.Duration(), check.Equals, time.Minute)
c.Check(err, check.NotNil)
c.Check(stats(), check.Matches, `.*"StatOps":[^0],.*`)
c.Check(stats(), check.Matches, `.*"Errors":[^0],.*`)
- c.Check(stats(), check.Matches, `.*"\*os\.PathError":[^0].*`)
+ c.Check(stats(), check.Matches, `.*"\*(fs|os)\.PathError":[^0].*`) // os.PathError changed to fs.PathError in Go 1.16
c.Check(stats(), check.Matches, `.*"InBytes":0,.*`)
c.Check(stats(), check.Matches, `.*"OpenOps":0,.*`)
c.Check(stats(), check.Matches, `.*"CreateOps":0,.*`)