2020-06-05 13:15:11 -04:00
|
|
|
package common
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2020-12-17 16:29:25 -05:00
|
|
|
"github.com/hashicorp/packer-plugin-sdk/communicator"
|
2020-06-05 13:15:11 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestCommHost(t *testing.T) {
|
|
|
|
state := testState(t)
|
|
|
|
config := SSHConfig{
|
|
|
|
Comm: communicator.Config{
|
2020-06-05 17:05:59 -04:00
|
|
|
Type: "ssh",
|
2020-06-05 13:15:11 -04:00
|
|
|
SSH: communicator.SSH{
|
|
|
|
SSHHost: "127.0.0.1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
hostFunc := CommHost(&config)
|
|
|
|
out, err := hostFunc(state)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("Should not have had an error")
|
|
|
|
}
|
|
|
|
|
|
|
|
if out != "127.0.0.1" {
|
|
|
|
t.Fatalf("Should have respected ssh override.")
|
|
|
|
}
|
|
|
|
}
|