mirror of
https://github.com/appleboy/drone-scp.git
synced 2026-06-04 18:23:59 +08:00
@@ -70,9 +70,15 @@ func trimPath(keys []string) []string {
|
||||
func (p Plugin) Exec() error {
|
||||
|
||||
if len(p.Config.Host) == 0 || len(p.Config.Username) == 0 || (len(p.Config.Password) == 0 && len(p.Config.Key) == 0) {
|
||||
log.Println("missing ssh config")
|
||||
log.Println("missing ssh config (Host, Username, Password or Key)")
|
||||
|
||||
return errors.New("missing ssh config")
|
||||
return errors.New("missing ssh config (Host, Username, Password or Key)")
|
||||
}
|
||||
|
||||
if len(p.Config.Source) == 0 {
|
||||
log.Println("missing source file list config")
|
||||
|
||||
return errors.New("missing source file list config")
|
||||
}
|
||||
|
||||
files := trimPath(p.Config.Source)
|
||||
|
||||
@@ -27,6 +27,21 @@ func TestMissingSSHConfig(t *testing.T) {
|
||||
assert.NotNil(t, err)
|
||||
}
|
||||
|
||||
func TestMissingSourceConfig(t *testing.T) {
|
||||
plugin := Plugin{
|
||||
Config: Config{
|
||||
Host: "example.com",
|
||||
Username: "ubuntu",
|
||||
Port: "443",
|
||||
Password: "1234",
|
||||
},
|
||||
}
|
||||
|
||||
err := plugin.Exec()
|
||||
|
||||
assert.NotNil(t, err)
|
||||
}
|
||||
|
||||
func TestTrimElement(t *testing.T) {
|
||||
var input, result []string
|
||||
|
||||
|
||||
Reference in New Issue
Block a user