mirror of
https://github.com/appleboy/drone-ssh.git
synced 2025-07-02 21:52:51 +08:00
test: enable comprehensive debugging in plugin execution
- Add debug logging to `exec` function in `plugin.go` - Enable debug mode in `TestCommandOutput` and `TestSudoCommand` tests - Remove redundant command blocks from multiple tests in `plugin_test.go` Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
parent
e28acf4f3b
commit
f3ec458f57
@ -105,9 +105,11 @@ func (p Plugin) exec(host string, wg *sync.WaitGroup, errChannel chan error) {
|
||||
},
|
||||
}
|
||||
|
||||
p.log(host, "======CMD======")
|
||||
p.log(host, strings.Join(p.Config.Script, "\n"))
|
||||
p.log(host, "======END======")
|
||||
if p.Config.Debug {
|
||||
p.log(host, "======CMD======")
|
||||
p.log(host, strings.Join(p.Config.Script, "\n"))
|
||||
p.log(host, "======END======")
|
||||
}
|
||||
|
||||
env := []string{}
|
||||
if p.Config.AllEnvs {
|
||||
|
@ -392,6 +392,7 @@ func TestCommandOutput(t *testing.T) {
|
||||
},
|
||||
CommandTimeout: 60 * time.Second,
|
||||
Sync: true,
|
||||
Debug: true,
|
||||
},
|
||||
Writer: &buffer,
|
||||
}
|
||||
@ -477,10 +478,6 @@ func TestScriptStopWithMultipleHostAndSyncMode(t *testing.T) {
|
||||
var (
|
||||
buffer bytes.Buffer
|
||||
expected = `
|
||||
======CMD======
|
||||
mkdir a/b/c
|
||||
mkdir d/e/f
|
||||
======END======
|
||||
err: mkdir: can't create directory 'a/b/c': No such file or directory
|
||||
`
|
||||
)
|
||||
@ -512,10 +509,6 @@ func TestScriptStop(t *testing.T) {
|
||||
var (
|
||||
buffer bytes.Buffer
|
||||
expected = `
|
||||
======CMD======
|
||||
mkdir a/b/c
|
||||
mkdir d/e/f
|
||||
======END======
|
||||
err: mkdir: can't create directory 'a/b/c': No such file or directory
|
||||
`
|
||||
)
|
||||
@ -546,10 +539,6 @@ func TestNoneScriptStop(t *testing.T) {
|
||||
var (
|
||||
buffer bytes.Buffer
|
||||
expected = `
|
||||
======CMD======
|
||||
mkdir a/b/c
|
||||
mkdir d/e/f
|
||||
======END======
|
||||
err: mkdir: can't create directory 'a/b/c': No such file or directory
|
||||
err: mkdir: can't create directory 'd/e/f': No such file or directory
|
||||
`
|
||||
@ -733,10 +722,6 @@ func TestUseInsecureCipher(t *testing.T) {
|
||||
var (
|
||||
buffer bytes.Buffer
|
||||
expected = `
|
||||
======CMD======
|
||||
mkdir a/b/c
|
||||
mkdir d/e/f
|
||||
======END======
|
||||
err: mkdir: can't create directory 'a/b/c': No such file or directory
|
||||
err: mkdir: can't create directory 'd/e/f': No such file or directory
|
||||
`
|
||||
@ -889,11 +874,6 @@ func TestAllEnvs(t *testing.T) {
|
||||
var (
|
||||
buffer bytes.Buffer
|
||||
expected = `
|
||||
======CMD======
|
||||
echo "[${INPUT_1}]"
|
||||
echo "[${GITHUB_2}]"
|
||||
echo "[${PLUGIN_3}]"
|
||||
======END======
|
||||
out: [foobar]
|
||||
out: [foobar]
|
||||
out: [foobar]
|
||||
@ -956,6 +936,7 @@ func TestSudoCommand(t *testing.T) {
|
||||
},
|
||||
CommandTimeout: 10 * time.Second,
|
||||
RequireTty: true,
|
||||
Debug: true,
|
||||
},
|
||||
Writer: &buffer,
|
||||
}
|
||||
@ -968,9 +949,6 @@ func TestCommandWithIPv6(t *testing.T) {
|
||||
var (
|
||||
buffer bytes.Buffer
|
||||
expected = `
|
||||
======CMD======
|
||||
whoami
|
||||
======END======
|
||||
out: drone-scp
|
||||
`
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user