diff options
| author | Dave Henderson <dhenderson@gmail.com> | 2021-01-23 15:16:57 -0500 |
|---|---|---|
| committer | Dave Henderson <dhenderson@gmail.com> | 2021-01-23 16:59:01 -0500 |
| commit | dab034d8edaabd1c183f99c33815dae151af6ab4 (patch) | |
| tree | 81e07d096c7215f0d5a04ba7c30f4b553311b76f /plugins_test.go | |
| parent | f20592a0422a12774474e61f28dbcade280a5909 (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.go | 20 |
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))) +} |
