mirror of
https://github.com/appleboy/drone-ssh.git
synced 2025-05-09 18:23:21 +08:00
test: improve IPv6 command execution tests
- Add a new test function `TestCommandWithIPv6` to check command execution with an IPv6 address - Initialize test variables and expected output for the IPv6 command test - Set up a `Plugin` struct with IPv6 host, user, port, key path, script, and command timeout for testing - Verify that `plugin.Exec()` returns `nil` (no error) in the IPv6 test - Assert that the output of the command execution matches the expected output in the IPv6 test Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
parent
e2d81857ec
commit
b4a636dbda
@ -949,3 +949,32 @@ func TestSudoCommand(t *testing.T) {
|
|||||||
assert.Nil(t, plugin.Exec())
|
assert.Nil(t, plugin.Exec())
|
||||||
assert.Equal(t, unindent(expected), unindent(buffer.String()))
|
assert.Equal(t, unindent(expected), unindent(buffer.String()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCommandWithIPv6(t *testing.T) {
|
||||||
|
var (
|
||||||
|
buffer bytes.Buffer
|
||||||
|
expected = `
|
||||||
|
======CMD======
|
||||||
|
whoami
|
||||||
|
======END======
|
||||||
|
out: drone-scp
|
||||||
|
`
|
||||||
|
)
|
||||||
|
|
||||||
|
plugin := Plugin{
|
||||||
|
Config: Config{
|
||||||
|
Host: []string{"::1"},
|
||||||
|
Username: "drone-scp",
|
||||||
|
Port: 22,
|
||||||
|
KeyPath: "./tests/.ssh/id_rsa",
|
||||||
|
Script: []string{
|
||||||
|
"whoami",
|
||||||
|
},
|
||||||
|
CommandTimeout: 10 * time.Second,
|
||||||
|
},
|
||||||
|
Writer: &buffer,
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.Nil(t, plugin.Exec())
|
||||||
|
assert.Equal(t, unindent(expected), unindent(buffer.String()))
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user