github.com/justinjmoses/evergreen@v0.0.0-20170530173719-1d50e381ff0d/remote/ssh_test.go (about) 1 package remote 2 3 import ( 4 "testing" 5 "time" 6 7 "github.com/evergreen-ci/evergreen/command" 8 . "github.com/smartystreets/goconvey/convey" 9 ) 10 11 func TestSSHCommand(t *testing.T) { 12 t.Skipf("the fixtures for remote ssh are not properly configured/conceived.") 13 14 Convey("When sshing", t, func() { 15 16 Convey("a simple command should execute successfully and provide the"+ 17 " correct output", func() { 18 19 cmd := &SSHCommand{ 20 Command: "echo 'hi stdout'; echo 'hi stderr' 1>&2", 21 Host: command.TestRemote + ":22", 22 User: command.TestRemoteUser, 23 Keyfile: command.TestRemoteKey, 24 Timeout: 1 * time.Second, 25 } 26 27 output, err := cmd.Run() 28 So(err, ShouldBeNil) 29 So(output, ShouldResemble, []byte("hi stdout\r\nhi stderr\r\n")) 30 31 }) 32 33 Convey("if a command times out, it should be killed appropriately", func() { 34 35 cmd := &SSHCommand{ 36 Command: "sleep 10", 37 Host: command.TestRemote + ":22", 38 User: command.TestRemoteUser, 39 Keyfile: command.TestRemoteKey, 40 Timeout: 500 * time.Millisecond, 41 } 42 43 output, err := cmd.Run() 44 So(err, ShouldEqual, ErrCmdTimedOut) 45 So(output, ShouldEqual, nil) 46 47 }) 48 49 }) 50 51 }