From 51d072fb24a69336c09fe4320102f5797db0d5e0 Mon Sep 17 00:00:00 2001 From: Tom Clegg Date: Tue, 4 May 2021 13:52:08 -0400 Subject: [PATCH] Update tests for go 1.16. No issue # Arvados-DCO-1.1-Signed-off-by: Tom Clegg --- build/run-tests.sh | 8 ++++++++ sdk/go/arvados/duration.go | 2 +- sdk/go/arvados/duration_test.go | 8 ++++---- services/keepstore/unix_volume_test.go | 2 +- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/build/run-tests.sh b/build/run-tests.sh index d6dc43416a..e309d24011 100755 --- a/build/run-tests.sh +++ b/build/run-tests.sh @@ -1147,6 +1147,14 @@ test_all() { do_test apps/workbench_profile } +test_go() { + do_test gofmt + for g in "${gostuff[@]}" + do + do_test "$g" go + done +} + help_interactive() { echo "== Interactive commands:" echo "TARGET (short for 'test DIR')" diff --git a/sdk/go/arvados/duration.go b/sdk/go/arvados/duration.go index ee482fdf31..c922f0a30d 100644 --- a/sdk/go/arvados/duration.go +++ b/sdk/go/arvados/duration.go @@ -22,7 +22,7 @@ func (d *Duration) UnmarshalJSON(data []byte) error { } // 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. diff --git a/sdk/go/arvados/duration_test.go b/sdk/go/arvados/duration_test.go index 86fe218c33..fa0ef0aeca 100644 --- a/sdk/go/arvados/duration_test.go +++ b/sdk/go/arvados/duration_test.go @@ -50,13 +50,13 @@ func (s *DurationSuite) TestUnmarshalJSON(c *check.C) { 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) diff --git a/services/keepstore/unix_volume_test.go b/services/keepstore/unix_volume_test.go index 6b42dbc519..1660858098 100644 --- a/services/keepstore/unix_volume_test.go +++ b/services/keepstore/unix_volume_test.go @@ -395,7 +395,7 @@ func (s *UnixVolumeSuite) TestStats(c *check.C) { 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,.*`) -- 2.30.2