osutil: adjust StreamCommand tests for golang 1.9
authorZygmunt Krynicki <me@zygoon.pl>
Fri, 8 Sep 2017 08:52:58 +0000 (10:52 +0200)
committerMichael Hudson-Doyle <mwhudson@debian.org>
Tue, 26 Sep 2017 17:41:53 +0000 (18:41 +0100)
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 <me@zygoon.pl>
Gbp-Pq: Name 0001-osutil-adjust-StreamCommand-tests-for-golang-1.9.patch

osutil/exec_test.go

index c6ba4654dec284484d34ad091575a6676a2f5549..6818a3ac41e45124b8ceb04e8f8d2264e2122be5 100644 (file)
@@ -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
 }