mirror of
https://github.com/moby/moby.git
synced 2026-01-11 10:41:43 +00:00
Use a more idiomatic name so that it can be used as `client.New()`. We should look if we want `New()` to have different / updated defaults i.e., enable `WithEnv` as default, and have an opt-out and have API- version negotiation enabled by default (with an opt-out option). Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
65 lines
1.9 KiB
Go
65 lines
1.9 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/moby/moby/client"
|
|
"github.com/moby/moby/v2/integration-cli/cli"
|
|
"github.com/moby/moby/v2/internal/testutil"
|
|
"gotest.tools/v3/assert"
|
|
is "gotest.tools/v3/assert/cmp"
|
|
)
|
|
|
|
type DockerCLIPluginLogDriverSuite struct {
|
|
ds *DockerSuite
|
|
}
|
|
|
|
func (s *DockerCLIPluginLogDriverSuite) TearDownTest(ctx context.Context, t *testing.T) {
|
|
s.ds.TearDownTest(ctx, t)
|
|
}
|
|
|
|
func (s *DockerCLIPluginLogDriverSuite) OnTimeout(t *testing.T) {
|
|
s.ds.OnTimeout(t)
|
|
}
|
|
|
|
func (s *DockerCLIPluginLogDriverSuite) TestPluginLogDriver(c *testing.T) {
|
|
testRequires(c, IsAmd64, DaemonIsLinux)
|
|
|
|
const pluginName = "cpuguy83/docker-logdriver-test:latest"
|
|
|
|
cli.DockerCmd(c, "plugin", "install", pluginName)
|
|
cli.DockerCmd(c, "run", "--log-driver", pluginName, "--name=test", "busybox", "echo", "hello")
|
|
out := cli.DockerCmd(c, "logs", "test").Combined()
|
|
assert.Equal(c, strings.TrimSpace(out), "hello")
|
|
|
|
cli.DockerCmd(c, "start", "-a", "test")
|
|
out = cli.DockerCmd(c, "logs", "test").Combined()
|
|
assert.Equal(c, strings.TrimSpace(out), "hello\nhello") //nolint:dupword
|
|
|
|
cli.DockerCmd(c, "rm", "test")
|
|
cli.DockerCmd(c, "plugin", "disable", pluginName)
|
|
cli.DockerCmd(c, "plugin", "rm", pluginName)
|
|
}
|
|
|
|
// Make sure log drivers are listed in info, and v2 plugins are not.
|
|
func (s *DockerCLIPluginLogDriverSuite) TestPluginLogDriverInfoList(c *testing.T) {
|
|
testRequires(c, IsAmd64, DaemonIsLinux)
|
|
const pluginName = "cpuguy83/docker-logdriver-test"
|
|
|
|
cli.DockerCmd(c, "plugin", "install", pluginName)
|
|
|
|
apiClient, err := client.New(client.FromEnv)
|
|
assert.NilError(c, err)
|
|
defer apiClient.Close()
|
|
|
|
result, err := apiClient.Info(testutil.GetContext(c), client.InfoOptions{})
|
|
assert.NilError(c, err)
|
|
info := result.Info
|
|
|
|
drivers := strings.Join(info.Plugins.Log, " ")
|
|
assert.Assert(c, is.Contains(drivers, "json-file"))
|
|
assert.Assert(c, !strings.Contains(drivers, pluginName))
|
|
}
|