File: dial_test.go

package info (click to toggle)
docker.io 27.5.1%2Bdfsg4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 67,384 kB
  • sloc: sh: 5,847; makefile: 1,146; ansic: 664; python: 162; asm: 133
file content (30 lines) | stat: -rw-r--r-- 1,176 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package cliplugins

import (
	"os"
	"path/filepath"
	"testing"

	"github.com/docker/cli/cli-plugins/manager"
	"gotest.tools/v3/assert"
	is "gotest.tools/v3/assert/cmp"
	"gotest.tools/v3/icmd"
)

func TestCLIPluginDialStdio(t *testing.T) {
	if os.Getenv("DOCKER_CLI_PLUGIN_USE_DIAL_STDIO") == "" {
		t.Skip("skipping plugin dial-stdio test since DOCKER_CLI_PLUGIN_USE_DIAL_STDIO is not set")
	}

	// Run the helloworld plugin forcing /bin/true as the `system
	// dial-stdio` target. It should be passed all arguments from
	// before the `helloworld` arg, but not the --who=foo which
	// follows. We observe this from the debug level logging from
	// the connhelper stuff.
	helloworld := filepath.Join(os.Getenv("DOCKER_CLI_E2E_PLUGINS_EXTRA_DIRS"), "docker-helloworld")
	cmd := icmd.Command(helloworld, "--config=blah", "--log-level", "debug", "helloworld", "--who=foo")
	res := icmd.RunCmd(cmd, icmd.WithEnv(manager.ReexecEnvvar+"=/bin/true"))
	res.Assert(t, icmd.Success)
	assert.Assert(t, is.Contains(res.Stderr(), `msg="commandconn: starting /bin/true with [--config=blah --log-level debug system dial-stdio]"`))
	assert.Assert(t, is.Equal(res.Stdout(), "Hello foo!\n"))
}