func TestComputeHost(t *testing.T) {
	Convey("Testing computeHost()", t, func() {
		config := config.New()

		err := config.LoadConfig(strings.NewReader(configExample))
		host, err := computeHost("aaa", 0, config)
		So(err, ShouldBeNil)
		So(host.HostName, ShouldEqual, "1.2.3.4")
		So(host.Port, ShouldEqual, "22")

		err = config.LoadConfig(strings.NewReader(configExample))
		host, err = computeHost("aaa", 42, config)
		So(err, ShouldBeNil)
		So(host.HostName, ShouldEqual, "1.2.3.4")
		So(host.Port, ShouldEqual, "42")

		err = config.LoadConfig(strings.NewReader(configExample))
		host, err = computeHost("eee", 0, config)
		So(err, ShouldBeNil)
		So(host.HostName, ShouldEqual, "eee")
		So(host.Port, ShouldEqual, "22")

		err = config.LoadConfig(strings.NewReader(configExample))
		host, err = computeHost("eee", 42, config)
		So(err, ShouldBeNil)
		So(host.HostName, ShouldEqual, "eee")
		So(host.Port, ShouldEqual, "42")
	})
}
func Test_proxyCommand(t *testing.T) {
	Convey("Testing proxyCommand()", t, func() {
		// FIXME: test stdout
		config := config.New()
		err := config.LoadConfig(strings.NewReader(configExample))
		host, err := computeHost("aaa", 0, config)
		So(err, ShouldBeNil)

		err = proxyCommand(host, "echo test from proxyCommand", false)
		So(err, ShouldBeNil)

		err = proxyCommand(host, "/bin/sh -c 'echo test from proxyCommand'", false)
		So(err, ShouldBeNil)

		err = proxyCommand(host, "/bin/sh -c 'exit 1'", false)
		So(err, ShouldNotBeNil)

		err = proxyCommand(host, "blah", true)
		So(err, ShouldResemble, fmt.Errorf("dry-run: Execute [blah]"))
	})
}
func Test_hostPrepare(t *testing.T) {
	Convey("Testing hostPrepare()", t, func() {
		config := config.New()
		err := config.LoadConfig(strings.NewReader(configExample))

		host, err := computeHost("aaa", 0, config)
		So(err, ShouldBeNil)
		So(host.HostName, ShouldEqual, "1.2.3.4")
		So(hostPrepare(host), ShouldBeNil)
		So(host.HostName, ShouldEqual, "1.2.3.4")

		host, err = computeHost("bbb", 0, config)
		So(err, ShouldBeNil)
		So(host.HostName, ShouldEqual, "bbb")
		So(hostPrepare(host), ShouldBeNil)
		So(host.HostName, ShouldEqual, "bbb")

		host, err = computeHost("eee", 0, config)
		So(err, ShouldBeNil)
		So(host.HostName, ShouldEqual, "eee")
		So(hostPrepare(host), ShouldBeNil)
		So(host.HostName, ShouldEqual, "42.42.42.42")
	})
}