github.com/mhilton/juju-juju@v0.0.0-20150901100907-a94dd2c73455/worker/networker/utils_test.go (about) 1 // Copyright 2014 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package networker_test 5 6 import ( 7 "runtime" 8 9 gc "gopkg.in/check.v1" 10 11 "github.com/juju/juju/testing" 12 "github.com/juju/juju/worker/networker" 13 ) 14 15 type utilsSuite struct { 16 testing.BaseSuite 17 } 18 19 var _ = gc.Suite(&utilsSuite{}) 20 21 func (s *utilsSuite) TestExecuteCommands(c *gc.C) { 22 //TODO(bogdanteleaga): Fix this on windows 23 if runtime.GOOS == "windows" { 24 c.Skip("bug 1403084: test uses bash scripts, will fix later on windows") 25 } 26 commands := []string{ 27 "echo start", 28 "sh -c 'echo STDOUT; echo STDERR >&2; exit 123'", 29 "echo end", 30 "exit 111", 31 } 32 err := networker.ExecuteCommands(commands) 33 expected := "command \"sh -c 'echo STDOUT; echo STDERR >&2; exit 123'\" failed " + 34 "(code: 123, stdout: STDOUT\n, stderr: STDERR\n)" 35 c.Assert(err, gc.NotNil) 36 c.Assert(err.Error(), gc.Equals, expected) 37 }