Merge branch 'main' into 18842-arv-mount-disk-config
[arvados.git] / sdk / go / arvados / duration_test.go
index fa0ef0aeca80d72448c65748efb6833e8db01812..40344d061b0682327ded9ab016a8865410a923d5 100644 (file)
@@ -56,8 +56,18 @@ func (s *DurationSuite) TestUnmarshalJSON(c *check.C) {
        err = json.Unmarshal([]byte(`{"D":"1"}`), &d)
        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)
+
+       d.D = Duration(time.Second)
+       err = json.Unmarshal([]byte(`{"D":"0"}`), &d)
+       c.Check(err, check.IsNil)
+       c.Check(d.D.Duration(), check.Equals, time.Duration(0))
+
+       d.D = Duration(time.Second)
+       err = json.Unmarshal([]byte(`{"D":0}`), &d)
+       c.Check(err, check.IsNil)
+       c.Check(d.D.Duration(), check.Equals, time.Duration(0))
 }