From a1518ac5c4376eafa941db5689e91e53b88dd0a0 Mon Sep 17 00:00:00 2001 From: Josh Komoroske Date: Mon, 26 Feb 2018 15:12:26 -0800 Subject: [PATCH] Tests for omitting unset variables --- plugin_test.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/plugin_test.go b/plugin_test.go index 175ecae..d58dc4c 100644 --- a/plugin_test.go +++ b/plugin_test.go @@ -257,6 +257,33 @@ func TestSetENV(t *testing.T) { assert.Nil(t, err) } +func TestSetExistingENV(t *testing.T) { + os.Setenv("FOO", "Value for foo") + os.Setenv("BAR", "") + plugin := Plugin{ + Config: Config{ + Host: []string{"localhost"}, + UserName: "drone-scp", + Port: 22, + KeyPath: "./tests/.ssh/id_rsa", + Secrets: []string{"FOO"}, + Envs: []string{"foo", "bar", "baz"}, + Debug: true, + Script: []string{"export FOO", "export BAR", "export BAZ", "env | grep -q '^FOO=Value for foo$'", "env | grep -q '^BAR=$'", "if env | grep -q BAZ; then false; else true; fi"}, + CommandTimeout: 1, + Proxy: easyssh.DefaultConfig{ + Server: "localhost", + User: "drone-scp", + Port: "22", + KeyPath: "./tests/.ssh/id_rsa", + }, + }, + } + + err := plugin.Exec() + assert.Nil(t, err) +} + func TestSyncMode(t *testing.T) { plugin := Plugin{ Config: Config{