Compare commits

...

2 Commits

Author SHA1 Message Date
Bo-Yi.Wu 4749cb1b43 chore: test
Signed-off-by: Bo-Yi.Wu <appleboy.tw@gmail.com>
2023-04-09 13:02:55 +08:00
Bo-Yi.Wu 716f1e7b6b chore: test
Signed-off-by: Bo-Yi.Wu <appleboy.tw@gmail.com>
2023-04-09 12:59:52 +08:00
+32
View File
@@ -723,3 +723,35 @@ func TestPlugin_buildArgs(t *testing.T) {
})
}
}
func TestCheckTargetFolderExist(t *testing.T) {
if os.Getenv("SSH_AUTH_SOCK") != "" {
if err := exec.Command("eval", "`ssh-agent -k`").Run(); err != nil {
t.Fatalf("exec: %v", err)
}
}
u, err := user.Lookup("drone-scp")
if err != nil {
t.Fatalf("Lookup: %v", err)
}
plugin := Plugin{
Config: Config{
Host: []string{"localhost"},
Username: "drone-scp",
Port: "22",
KeyPath: "tests/.ssh/id_rsa",
Source: []string{"tests/global/*"},
Target: []string{filepath.Join(u.HomeDir, "__test__")},
CommandTimeout: 60 * time.Second,
TarExec: "tar",
},
}
err = plugin.Exec()
assert.Nil(t, err)
err = plugin.Exec()
assert.Nil(t, err)
}