summaryrefslogtreecommitdiff
path: root/plugins_test.go
diff options
context:
space:
mode:
authorDave Henderson <dhenderson@gmail.com>2021-01-23 15:16:57 -0500
committerDave Henderson <dhenderson@gmail.com>2021-01-23 16:59:01 -0500
commitdab034d8edaabd1c183f99c33815dae151af6ab4 (patch)
tree81e07d096c7215f0d5a04ba7c30f4b553311b76f /plugins_test.go
parentf20592a0422a12774474e61f28dbcade280a5909 (diff)
Fix race condition in signal handling
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
Diffstat (limited to 'plugins_test.go')
-rw-r--r--plugins_test.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/plugins_test.go b/plugins_test.go
index d1fe52b1..8590ed34 100644
--- a/plugins_test.go
+++ b/plugins_test.go
@@ -1,9 +1,12 @@
package gomplate
import (
+ "bytes"
"context"
+ "strings"
"testing"
"text/template"
+ "time"
"gotest.tools/v3/assert"
"gotest.tools/v3/assert/cmp"
@@ -54,3 +57,20 @@ func TestBuildCommand(t *testing.T) {
assert.DeepEqual(t, d.expected, actual)
}
}
+
+func TestRun(t *testing.T) {
+ ctx, cancel := context.WithCancel(context.Background())
+ defer cancel()
+
+ stderr := &bytes.Buffer{}
+ p := &plugin{
+ ctx: ctx,
+ timeout: 500 * time.Millisecond,
+ stderr: stderr,
+ path: "echo",
+ }
+ out, err := p.run("foo")
+ assert.NilError(t, err)
+ assert.Equal(t, "", stderr.String())
+ assert.Equal(t, "foo", strings.TrimSpace(out.(string)))
+}