From: Zygmunt Krynicki Date: Fri, 8 Sep 2017 08:52:58 +0000 (+0200) Subject: osutil: adjust StreamCommand tests for golang 1.9 X-Git-Tag: archive/raspbian/2.27.6-2+rpi1^2~7 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=337ae801ffdbe6642135c0775bd400e157c47861;p=snapd.git osutil: adjust StreamCommand tests for golang 1.9 In golang 1.9 there are richer error constructs returned from certain operations and tests were very precisely monitoring the result. This patch adjust tests to work on both golang 1.9 and earlier. Signed-off-by: Zygmunt Krynicki Gbp-Pq: Name 0001-osutil-adjust-StreamCommand-tests-for-golang-1.9.patch --- diff --git a/osutil/exec_test.go b/osutil/exec_test.go index c6ba4654..6818a3ac 100644 --- a/osutil/exec_test.go +++ b/osutil/exec_test.go @@ -207,8 +207,9 @@ func (s *execSuite) TestStreamCommandHappy(c *C) { wrf, wrc := osutil.WaitingReaderGuts(stdout) c.Assert(wrf, FitsTypeOf, &os.File{}) - c.Check(wrf.(*os.File).Close(), Equals, syscall.EINVAL) // i.e. already closed - c.Check(wrc.ProcessState, NotNil) // i.e. already waited for + // Depending on golang version the error is one of the two. + c.Check(wrf.(*os.File).Close(), ErrorMatches, "invalid argument|file already closed") + c.Check(wrc.ProcessState, NotNil) // i.e. already waited for } func (s *execSuite) TestStreamCommandSad(c *C) { @@ -221,6 +222,7 @@ func (s *execSuite) TestStreamCommandSad(c *C) { wrf, wrc := osutil.WaitingReaderGuts(stdout) c.Assert(wrf, FitsTypeOf, &os.File{}) - c.Check(wrf.(*os.File).Close(), Equals, syscall.EINVAL) // i.e. already closed - c.Check(wrc.ProcessState, NotNil) // i.e. already waited for + // Depending on golang version the error is one of the two. + c.Check(wrf.(*os.File).Close(), ErrorMatches, "invalid argument|file already closed") + c.Check(wrc.ProcessState, NotNil) // i.e. already waited for }