From e1cefccb1e58bd6de75e9eca80352ef88a9c06c3 Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Tue, 1 Aug 2017 12:00:06 +0800 Subject: [PATCH] add testing Signed-off-by: Bo-Yi Wu --- plugin_test.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/plugin_test.go b/plugin_test.go index 8fe9709..9466bef 100644 --- a/plugin_test.go +++ b/plugin_test.go @@ -1,6 +1,7 @@ package main import ( + "os" "testing" "github.com/appleboy/easyssh-proxy" @@ -229,3 +230,28 @@ func TestSSHCommandExitCodeError(t *testing.T) { err := plugin.Exec() assert.NotNil(t, err) } + +func TestSetENV(t *testing.T) { + os.Setenv("FOO", "1") + plugin := Plugin{ + Config: Config{ + Host: []string{"localhost"}, + UserName: "drone-scp", + Port: 22, + KeyPath: "./tests/.ssh/id_rsa", + Secrets: []string{"FOO"}, + Envs: []string{"FOO"}, + Script: []string{"whoami; echo $FOO"}, + CommandTimeout: 1, + Proxy: easyssh.DefaultConfig{ + Server: "localhost", + User: "drone-scp", + Port: "22", + KeyPath: "./tests/.ssh/id_rsa", + }, + }, + } + + err := plugin.Exec() + assert.Nil(t, err) +}