Append host if arguments are specified for ping input (#5450)
This commit is contained in:
parent
c18934f065
commit
e586fdb27f
|
@ -193,7 +193,7 @@ func hostPinger(binary string, timeout float64, args ...string) (string, error)
|
|||
// args returns the arguments for the 'ping' executable
|
||||
func (p *Ping) args(url string, system string) []string {
|
||||
if len(p.Arguments) > 0 {
|
||||
return p.Arguments
|
||||
return append(p.Arguments, url)
|
||||
}
|
||||
|
||||
// build the ping command args based on toml config
|
||||
|
|
|
@ -126,6 +126,7 @@ func TestArgs(t *testing.T) {
|
|||
|
||||
func TestArguments(t *testing.T) {
|
||||
arguments := []string{"-c", "3"}
|
||||
expected := append(arguments, "www.google.com")
|
||||
p := Ping{
|
||||
Count: 2,
|
||||
Interface: "eth0",
|
||||
|
@ -137,7 +138,7 @@ func TestArguments(t *testing.T) {
|
|||
|
||||
for _, system := range []string{"darwin", "linux", "anything else"} {
|
||||
actual := p.args("www.google.com", system)
|
||||
require.True(t, reflect.DeepEqual(actual, arguments), "Expected: %s Actual: %s", arguments, actual)
|
||||
require.True(t, reflect.DeepEqual(actual, expected), "Expected: %s Actual: %s", expected, actual)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue