f337a52a |
package main
import ( |
2f2779b6 |
"encoding/json" |
231d362d |
"fmt" |
8d174a43 |
"os" |
231d362d |
"strconv" |
f337a52a |
"strings" |
59e55dcd |
"testing" |
c9207bc0 |
"time" |
dc944ea7 |
|
91e197d6 |
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container" |
9f0b3f56 |
"gotest.tools/v3/assert"
"gotest.tools/v3/icmd" |
f337a52a |
)
|
1d92789b |
func checkValidGraphDriver(c *testing.T, name string) { |
eedeeaf4 |
if name != "devicemapper" && name != "overlay" && name != "vfs" && name != "zfs" && name != "btrfs" && name != "aufs" {
c.Fatalf("%v is not a valid graph driver name", name)
}
}
|
1d92789b |
func (s *DockerSuite) TestInspectImage(c *testing.T) { |
f9a3558a |
testRequires(c, DaemonIsLinux) |
89367899 |
imageTest := "emptyfs" |
4352da78 |
// It is important that this ID remain stable. If a code change causes
// it to be different, this is equivalent to a cache bust when pulling
// a legacy-format manifest. If the check at the end of this function
// fails, fix the difference in the image serialization instead of
// updating this hash.
imageTestID := "sha256:11f64303f0f7ffdc71f001788132bca5346831939a956e3e975c93267d89a16d" |
62a856e9 |
id := inspectField(c, imageTest, "Id") |
ac24cabd |
|
6dc7f4c1 |
assert.Equal(c, id, imageTestID) |
f337a52a |
} |
b0ef3194 |
|
1d92789b |
func (s *DockerSuite) TestInspectInt64(c *testing.T) { |
ae29bd43 |
dockerCmd(c, "run", "-d", "-m=300M", "--name", "inspectTest", "busybox", "true") |
62a856e9 |
inspectOut := inspectField(c, "inspectTest", "HostConfig.Memory") |
6dc7f4c1 |
assert.Equal(c, inspectOut, "314572800") |
b0ef3194 |
} |
231d362d |
|
1d92789b |
func (s *DockerSuite) TestInspectDefault(c *testing.T) { |
580d3677 |
// Both the container and image are named busybox. docker inspect will fetch the container JSON.
// If the container JSON is not available, it will go for the image JSON. |
2cb74e69 |
|
9fbb1306 |
out, _ := dockerCmd(c, "run", "--name=busybox", "-d", "busybox", "true")
containerID := strings.TrimSpace(out)
|
62a856e9 |
inspectOut := inspectField(c, "busybox", "Id") |
6dc7f4c1 |
assert.Equal(c, strings.TrimSpace(inspectOut), containerID) |
2cb74e69 |
}
|
1d92789b |
func (s *DockerSuite) TestInspectStatus(c *testing.T) { |
a899aa67 |
out := runSleepingContainer(c, "-d") |
fed85c32 |
out = strings.TrimSpace(out)
|
62a856e9 |
inspectOut := inspectField(c, out, "State.Status") |
6dc7f4c1 |
assert.Equal(c, inspectOut, "running") |
fed85c32 |
|
3ae6cd45 |
// Windows does not support pause/unpause on Windows Server Containers.
// (RS1 does for Hyper-V Containers, but production CI is not setup for that) |
18a771a7 |
if testEnv.OSType != "windows" { |
3ae6cd45 |
dockerCmd(c, "pause", out)
inspectOut = inspectField(c, out, "State.Status") |
6dc7f4c1 |
assert.Equal(c, inspectOut, "paused") |
fed85c32 |
|
3ae6cd45 |
dockerCmd(c, "unpause", out)
inspectOut = inspectField(c, out, "State.Status") |
6dc7f4c1 |
assert.Equal(c, inspectOut, "running") |
3ae6cd45 |
} |
fed85c32 |
dockerCmd(c, "stop", out) |
62a856e9 |
inspectOut = inspectField(c, out, "State.Status") |
6dc7f4c1 |
assert.Equal(c, inspectOut, "exited") |
eedeeaf4 |
|
fed85c32 |
}
|
1d92789b |
func (s *DockerSuite) TestInspectTypeFlagContainer(c *testing.T) { |
580d3677 |
// Both the container and image are named busybox. docker inspect will fetch container
// JSON State.Running field. If the field is true, it's a container. |
3ae6cd45 |
runSleepingContainer(c, "--name=busybox", "-d") |
2cb74e69 |
|
fab2a3dc |
formatStr := "--format={{.State.Running}}" |
eedeeaf4 |
out, _ := dockerCmd(c, "inspect", "--type=container", formatStr, "busybox") |
6345208b |
assert.Equal(c, out, "true\n") // not a container JSON |
2cb74e69 |
}
|
1d92789b |
func (s *DockerSuite) TestInspectTypeFlagWithNoContainer(c *testing.T) { |
580d3677 |
// Run this test on an image named busybox. docker inspect will try to fetch container
// JSON. Since there is no container named busybox and --type=container, docker inspect will
// not try to get the image JSON. It will throw an error. |
2cb74e69 |
|
668e2369 |
dockerCmd(c, "run", "-d", "busybox", "true") |
2cb74e69 |
|
eedeeaf4 |
_, _, err := dockerCmdWithError("inspect", "--type=container", "busybox")
// docker inspect should fail, as there is no container named busybox |
6345208b |
assert.ErrorContains(c, err, "") |
2cb74e69 |
}
|
1d92789b |
func (s *DockerSuite) TestInspectTypeFlagWithImage(c *testing.T) { |
580d3677 |
// Both the container and image are named busybox. docker inspect will fetch image
// JSON as --type=image. if there is no image with name busybox, docker inspect
// will throw an error. |
2cb74e69 |
|
668e2369 |
dockerCmd(c, "run", "--name=busybox", "-d", "busybox", "true") |
2cb74e69 |
|
eedeeaf4 |
out, _ := dockerCmd(c, "inspect", "--type=image", "busybox") |
931edfe5 |
// not an image JSON |
4e2e486b |
assert.Assert(c, !strings.Contains(out, "State")) |
2cb74e69 |
}
|
1d92789b |
func (s *DockerSuite) TestInspectTypeFlagWithInvalidValue(c *testing.T) { |
580d3677 |
// Both the container and image are named busybox. docker inspect will fail
// as --type=foobar is not a valid value for the flag. |
2cb74e69 |
|
668e2369 |
dockerCmd(c, "run", "--name=busybox", "-d", "busybox", "true") |
2cb74e69 |
|
693ba98c |
out, exitCode, err := dockerCmdWithError("inspect", "--type=foobar", "busybox") |
0fabf3e4 |
assert.Assert(c, err != nil, "%d", exitCode) |
a2024a54 |
assert.Equal(c, exitCode, 1, fmt.Sprintf("%s", err)) |
98f2638f |
assert.Assert(c, strings.Contains(out, "not a valid value for --type")) |
2cb74e69 |
}
|
1d92789b |
func (s *DockerSuite) TestInspectImageFilterInt(c *testing.T) { |
f9a3558a |
testRequires(c, DaemonIsLinux) |
231d362d |
imageTest := "emptyfs" |
62a856e9 |
out := inspectField(c, imageTest, "Size") |
74f8a4ec |
size, err := strconv.Atoi(out) |
0fabf3e4 |
assert.Assert(c, err == nil, "failed to inspect size of the image: %s, %v", out, err) |
231d362d |
//now see if the size turns out to be the same |
fab2a3dc |
formatStr := fmt.Sprintf("--format={{eq .Size %d}}", size) |
eedeeaf4 |
out, _ = dockerCmd(c, "inspect", formatStr, imageTest)
result, err := strconv.ParseBool(strings.TrimSuffix(out, "\n")) |
6345208b |
assert.NilError(c, err) |
6dc7f4c1 |
assert.Equal(c, result, true) |
231d362d |
}
|
1d92789b |
func (s *DockerSuite) TestInspectContainerFilterInt(c *testing.T) { |
def13fa2 |
result := icmd.RunCmd(icmd.Cmd{
Command: []string{dockerBinary, "run", "-i", "-a", "stdin", "busybox", "cat"},
Stdin: strings.NewReader("blahblah"),
})
result.Assert(c, icmd.Success)
out := result.Stdout() |
231d362d |
id := strings.TrimSpace(out)
|
62a856e9 |
out = inspectField(c, id, "State.ExitCode") |
74f8a4ec |
exitCode, err := strconv.Atoi(out) |
0fabf3e4 |
assert.Assert(c, err == nil, "failed to inspect exitcode of the container: %s, %v", out, err) |
231d362d |
//now get the exit code to verify |
fab2a3dc |
formatStr := fmt.Sprintf("--format={{eq .State.ExitCode %d}}", exitCode) |
668e2369 |
out, _ = dockerCmd(c, "inspect", formatStr, id) |
def13fa2 |
inspectResult, err := strconv.ParseBool(strings.TrimSuffix(out, "\n")) |
6345208b |
assert.NilError(c, err) |
6dc7f4c1 |
assert.Equal(c, inspectResult, true) |
231d362d |
} |
407a626b |
|
1d92789b |
func (s *DockerSuite) TestInspectImageGraphDriver(c *testing.T) { |
337ee2aa |
testRequires(c, DaemonIsLinux, Devicemapper) |
407a626b |
imageTest := "emptyfs" |
62a856e9 |
name := inspectField(c, imageTest, "GraphDriver.Name") |
407a626b |
|
eedeeaf4 |
checkValidGraphDriver(c, name) |
407a626b |
|
62a856e9 |
deviceID := inspectField(c, imageTest, "GraphDriver.Data.DeviceId") |
407a626b |
|
62a856e9 |
_, err := strconv.Atoi(deviceID) |
0fabf3e4 |
assert.Assert(c, err == nil, "failed to inspect DeviceId of the image: %s, %v", deviceID, err) |
407a626b |
|
62a856e9 |
deviceSize := inspectField(c, imageTest, "GraphDriver.Data.DeviceSize") |
407a626b |
_, err = strconv.ParseUint(deviceSize, 10, 64) |
0fabf3e4 |
assert.Assert(c, err == nil, "failed to inspect DeviceSize of the image: %s, %v", deviceSize, err) |
407a626b |
}
|
1d92789b |
func (s *DockerSuite) TestInspectContainerGraphDriver(c *testing.T) { |
337ee2aa |
testRequires(c, DaemonIsLinux, Devicemapper)
|
668e2369 |
out, _ := dockerCmd(c, "run", "-d", "busybox", "true") |
407a626b |
out = strings.TrimSpace(out)
|
62a856e9 |
name := inspectField(c, out, "GraphDriver.Name") |
407a626b |
|
eedeeaf4 |
checkValidGraphDriver(c, name) |
407a626b |
|
62a856e9 |
imageDeviceID := inspectField(c, "busybox", "GraphDriver.Data.DeviceId") |
a7e09683 |
|
62a856e9 |
deviceID := inspectField(c, out, "GraphDriver.Data.DeviceId") |
407a626b |
|
0fa116fa |
assert.Assert(c, imageDeviceID != deviceID) |
a7e09683 |
|
62a856e9 |
_, err := strconv.Atoi(deviceID) |
0fabf3e4 |
assert.Assert(c, err == nil, "failed to inspect DeviceId of the image: %s, %v", deviceID, err) |
407a626b |
|
62a856e9 |
deviceSize := inspectField(c, out, "GraphDriver.Data.DeviceSize") |
407a626b |
_, err = strconv.ParseUint(deviceSize, 10, 64) |
0fabf3e4 |
assert.Assert(c, err == nil, "failed to inspect DeviceSize of the image: %s, %v", deviceSize, err) |
407a626b |
} |
1c3cb2d3 |
|
1d92789b |
func (s *DockerSuite) TestInspectBindMountPoint(c *testing.T) { |
8d174a43 |
modifier := ",z"
prefix, slash := getPrefixAndSlashFromDaemonPlatform() |
18a771a7 |
if testEnv.OSType == "windows" { |
8d174a43 |
modifier = ""
// Linux creates the host directory if it doesn't exist. Windows does not.
os.Mkdir(`c:\data`, os.ModeDir)
}
dockerCmd(c, "run", "-d", "--name", "test", "-v", prefix+slash+"data:"+prefix+slash+"data:ro"+modifier, "busybox", "cat") |
1c3cb2d3 |
|
62a856e9 |
vol := inspectFieldJSON(c, "test", "Mounts") |
1c3cb2d3 |
var mp []types.MountPoint |
fb42e847 |
err := json.Unmarshal([]byte(vol), &mp) |
6345208b |
assert.NilError(c, err) |
1c3cb2d3 |
|
eedeeaf4 |
// check that there is only one mountpoint |
491ef7b9 |
assert.Equal(c, len(mp), 1) |
1c3cb2d3 |
m := mp[0]
|
6dc7f4c1 |
assert.Equal(c, m.Name, "")
assert.Equal(c, m.Driver, "")
assert.Equal(c, m.Source, prefix+slash+"data")
assert.Equal(c, m.Destination, prefix+slash+"data") |
18a771a7 |
if testEnv.OSType != "windows" { // Windows does not set mode |
6dc7f4c1 |
assert.Equal(c, m.Mode, "ro"+modifier) |
03816ad5 |
} |
6dc7f4c1 |
assert.Equal(c, m.RW, false) |
1c3cb2d3 |
} |
c9207bc0 |
|
1d92789b |
func (s *DockerSuite) TestInspectNamedMountPoint(c *testing.T) { |
6f2e8205 |
prefix, slash := getPrefixAndSlashFromDaemonPlatform()
dockerCmd(c, "run", "-d", "--name", "test", "-v", "data:"+prefix+slash+"data", "busybox", "cat")
vol := inspectFieldJSON(c, "test", "Mounts")
var mp []types.MountPoint |
fb42e847 |
err := json.Unmarshal([]byte(vol), &mp) |
6345208b |
assert.NilError(c, err) |
6f2e8205 |
// check that there is only one mountpoint |
491ef7b9 |
assert.Equal(c, len(mp), 1) |
6f2e8205 |
m := mp[0]
|
6dc7f4c1 |
assert.Equal(c, m.Name, "data")
assert.Equal(c, m.Driver, "local") |
0fa116fa |
assert.Assert(c, m.Source != "") |
6dc7f4c1 |
assert.Equal(c, m.Destination, prefix+slash+"data")
assert.Equal(c, m.RW, true) |
6f2e8205 |
}
|
c9207bc0 |
// #14947 |
1d92789b |
func (s *DockerSuite) TestInspectTimesAsRFC3339Nano(c *testing.T) { |
c9207bc0 |
out, _ := dockerCmd(c, "run", "-d", "busybox", "true")
id := strings.TrimSpace(out) |
62a856e9 |
startedAt := inspectField(c, id, "State.StartedAt")
finishedAt := inspectField(c, id, "State.FinishedAt")
created := inspectField(c, id, "Created") |
c9207bc0 |
|
62a856e9 |
_, err := time.Parse(time.RFC3339Nano, startedAt) |
6345208b |
assert.NilError(c, err) |
c9207bc0 |
_, err = time.Parse(time.RFC3339Nano, finishedAt) |
6345208b |
assert.NilError(c, err) |
c9207bc0 |
_, err = time.Parse(time.RFC3339Nano, created) |
6345208b |
assert.NilError(c, err) |
c9207bc0 |
|
62a856e9 |
created = inspectField(c, "busybox", "Created") |
c9207bc0 |
_, err = time.Parse(time.RFC3339Nano, created) |
6345208b |
assert.NilError(c, err) |
c9207bc0 |
} |
2f2779b6 |
// #15633 |
1d92789b |
func (s *DockerSuite) TestInspectLogConfigNoType(c *testing.T) { |
2f2779b6 |
dockerCmd(c, "create", "--name=test", "--log-opt", "max-file=42", "busybox") |
7ac4232e |
var logConfig container.LogConfig |
2f2779b6 |
|
62a856e9 |
out := inspectFieldJSON(c, "test", "HostConfig.LogConfig") |
2f2779b6 |
|
62a856e9 |
err := json.NewDecoder(strings.NewReader(out)).Decode(&logConfig) |
0fabf3e4 |
assert.Assert(c, err == nil, "%v", out) |
2f2779b6 |
|
6dc7f4c1 |
assert.Equal(c, logConfig.Type, "json-file") |
a2024a54 |
assert.Equal(c, logConfig.Config["max-file"], "42", fmt.Sprintf("%v", logConfig)) |
2f2779b6 |
} |
b4d6b238 |
|
1d92789b |
func (s *DockerSuite) TestInspectNoSizeFlagContainer(c *testing.T) { |
580d3677 |
// Both the container and image are named busybox. docker inspect will fetch container
// JSON SizeRw and SizeRootFs field. If there is no flag --size/-s, there are no size fields. |
b4d6b238 |
|
6a931c35 |
runSleepingContainer(c, "--name=busybox", "-d") |
b4d6b238 |
|
fab2a3dc |
formatStr := "--format={{.SizeRw}},{{.SizeRootFs}}" |
b4d6b238 |
out, _ := dockerCmd(c, "inspect", "--type=container", formatStr, "busybox") |
a2024a54 |
assert.Equal(c, strings.TrimSpace(out), "<nil>,<nil>", fmt.Sprintf("Expected not to display size info: %s", out)) |
b4d6b238 |
}
|
1d92789b |
func (s *DockerSuite) TestInspectSizeFlagContainer(c *testing.T) { |
6a931c35 |
runSleepingContainer(c, "--name=busybox", "-d") |
b4d6b238 |
|
3b9c1387 |
formatStr := "--format='{{.SizeRw}},{{.SizeRootFs}}'" |
b4d6b238 |
out, _ := dockerCmd(c, "inspect", "-s", "--type=container", formatStr, "busybox")
sz := strings.Split(out, ",")
|
0fa116fa |
assert.Assert(c, strings.TrimSpace(sz[0]) != "<nil>")
assert.Assert(c, strings.TrimSpace(sz[1]) != "<nil>") |
b4d6b238 |
}
|
1d92789b |
func (s *DockerSuite) TestInspectTemplateError(c *testing.T) { |
9fbb1306 |
// Template parsing error for both the container and image. |
b4d6b238 |
|
6a931c35 |
runSleepingContainer(c, "--name=container1", "-d") |
b4d6b238 |
|
9fbb1306 |
out, _, err := dockerCmdWithError("inspect", "--type=container", "--format='Format container: {{.ThisDoesNotExist}}'", "container1") |
74747b35 |
assert.Assert(c, err != nil) |
98f2638f |
assert.Assert(c, strings.Contains(out, "Template parsing error")) |
9fbb1306 |
out, _, err = dockerCmdWithError("inspect", "--type=image", "--format='Format container: {{.ThisDoesNotExist}}'", "busybox") |
74747b35 |
assert.Assert(c, err != nil) |
98f2638f |
assert.Assert(c, strings.Contains(out, "Template parsing error")) |
b4d6b238 |
} |
f1a74a89 |
|
1d92789b |
func (s *DockerSuite) TestInspectJSONFields(c *testing.T) { |
6a931c35 |
runSleepingContainer(c, "--name=busybox", "-d") |
fab2a3dc |
out, _, err := dockerCmdWithError("inspect", "--type=container", "--format={{.HostConfig.Dns}}", "busybox") |
f1a74a89 |
|
6345208b |
assert.NilError(c, err)
assert.Equal(c, out, "[]\n") |
f1a74a89 |
} |
61d62400 |
|
1d92789b |
func (s *DockerSuite) TestInspectByPrefix(c *testing.T) { |
62a856e9 |
id := inspectField(c, "busybox", "Id") |
6345208b |
assert.Assert(c, strings.HasPrefix(id, "sha256:")) |
61d62400 |
|
62a856e9 |
id2 := inspectField(c, id[:12], "Id") |
6dc7f4c1 |
assert.Equal(c, id, id2) |
61d62400 |
|
62a856e9 |
id3 := inspectField(c, strings.TrimPrefix(id, "sha256:")[:12], "Id") |
6dc7f4c1 |
assert.Equal(c, id, id3) |
61d62400 |
} |
57b67963 |
|
1d92789b |
func (s *DockerSuite) TestInspectStopWhenNotFound(c *testing.T) { |
fb1f22b0 |
runSleepingContainer(c, "--name=busybox1", "-d")
runSleepingContainer(c, "--name=busybox2", "-d")
result := dockerCmdWithResult("inspect", "--type=container", "--format='{{.Name}}'", "busybox1", "busybox2", "missing")
|
74747b35 |
assert.Assert(c, result.Error != nil) |
98f2638f |
assert.Assert(c, strings.Contains(result.Stdout(), "busybox1"))
assert.Assert(c, strings.Contains(result.Stdout(), "busybox2"))
assert.Assert(c, strings.Contains(result.Stderr(), "Error: No such container: missing")) |
fb1f22b0 |
// test inspect would not fast fail
result = dockerCmdWithResult("inspect", "--type=container", "--format='{{.Name}}'", "missing", "busybox1", "busybox2")
|
74747b35 |
assert.Assert(c, result.Error != nil) |
98f2638f |
assert.Assert(c, strings.Contains(result.Stdout(), "busybox1"))
assert.Assert(c, strings.Contains(result.Stdout(), "busybox2"))
assert.Assert(c, strings.Contains(result.Stderr(), "Error: No such container: missing")) |
57b67963 |
} |
d32f4301 |
|
1d92789b |
func (s *DockerSuite) TestInspectHistory(c *testing.T) { |
3ae6cd45 |
dockerCmd(c, "run", "--name=testcont", "busybox", "echo", "hello") |
d32f4301 |
dockerCmd(c, "commit", "-m", "test comment", "testcont", "testimg")
out, _, err := dockerCmdWithError("inspect", "--format='{{.Comment}}'", "testimg") |
6345208b |
assert.NilError(c, err) |
98f2638f |
assert.Assert(c, strings.Contains(out, "test comment")) |
d32f4301 |
} |
9f676ade |
|
1d92789b |
func (s *DockerSuite) TestInspectContainerNetworkDefault(c *testing.T) { |
9f676ade |
testRequires(c, DaemonIsLinux)
contName := "test1"
dockerCmd(c, "run", "--name", contName, "-d", "busybox", "top") |
4bd202b0 |
netOut, _ := dockerCmd(c, "network", "inspect", "--format={{.ID}}", "bridge") |
62a856e9 |
out := inspectField(c, contName, "NetworkSettings.Networks") |
98f2638f |
assert.Assert(c, strings.Contains(out, "bridge")) |
62a856e9 |
out = inspectField(c, contName, "NetworkSettings.Networks.bridge.NetworkID") |
6345208b |
assert.Equal(c, strings.TrimSpace(out), strings.TrimSpace(netOut)) |
9f676ade |
}
|
1d92789b |
func (s *DockerSuite) TestInspectContainerNetworkCustom(c *testing.T) { |
9f676ade |
testRequires(c, DaemonIsLinux)
netOut, _ := dockerCmd(c, "network", "create", "net1")
dockerCmd(c, "run", "--name=container1", "--net=net1", "-d", "busybox", "top") |
62a856e9 |
out := inspectField(c, "container1", "NetworkSettings.Networks") |
98f2638f |
assert.Assert(c, strings.Contains(out, "net1")) |
62a856e9 |
out = inspectField(c, "container1", "NetworkSettings.Networks.net1.NetworkID") |
6345208b |
assert.Equal(c, strings.TrimSpace(out), strings.TrimSpace(netOut)) |
9f676ade |
} |
14dc4a71 |
|
1d92789b |
func (s *DockerSuite) TestInspectRootFS(c *testing.T) { |
14dc4a71 |
out, _, err := dockerCmdWithError("inspect", "busybox") |
6345208b |
assert.NilError(c, err) |
14dc4a71 |
var imageJSON []types.ImageInspect
err = json.Unmarshal([]byte(out), &imageJSON) |
6345208b |
assert.NilError(c, err)
assert.Assert(c, len(imageJSON[0].RootFS.Layers) >= 1) |
14dc4a71 |
} |
0fa20ad1 |
|
1d92789b |
func (s *DockerSuite) TestInspectAmpersand(c *testing.T) { |
0fa20ad1 |
testRequires(c, DaemonIsLinux)
name := "test"
out, _ := dockerCmd(c, "run", "--name", name, "--env", `TEST_ENV="soanni&rtr"`, "busybox", "env") |
98f2638f |
assert.Assert(c, strings.Contains(out, `soanni&rtr`)) |
0fa20ad1 |
out, _ = dockerCmd(c, "inspect", name) |
98f2638f |
assert.Assert(c, strings.Contains(out, `soanni&rtr`)) |
0fa20ad1 |
} |
90bb2cdb |
|
1d92789b |
func (s *DockerSuite) TestInspectPlugin(c *testing.T) { |
ebff8c79 |
testRequires(c, DaemonIsLinux, IsAmd64, Network) |
90bb2cdb |
_, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", pNameWithTag) |
6345208b |
assert.NilError(c, err) |
90bb2cdb |
out, _, err := dockerCmdWithError("inspect", "--type", "plugin", "--format", "{{.Name}}", pNameWithTag) |
6345208b |
assert.NilError(c, err)
assert.Equal(c, strings.TrimSpace(out), pNameWithTag) |
90bb2cdb |
out, _, err = dockerCmdWithError("inspect", "--format", "{{.Name}}", pNameWithTag) |
6345208b |
assert.NilError(c, err)
assert.Equal(c, strings.TrimSpace(out), pNameWithTag) |
90bb2cdb |
// Even without tag the inspect still work |
3d86b0c7 |
out, _, err = dockerCmdWithError("inspect", "--type", "plugin", "--format", "{{.Name}}", pNameWithTag) |
6345208b |
assert.NilError(c, err)
assert.Equal(c, strings.TrimSpace(out), pNameWithTag) |
90bb2cdb |
|
3d86b0c7 |
out, _, err = dockerCmdWithError("inspect", "--format", "{{.Name}}", pNameWithTag) |
6345208b |
assert.NilError(c, err)
assert.Equal(c, strings.TrimSpace(out), pNameWithTag) |
90bb2cdb |
_, _, err = dockerCmdWithError("plugin", "disable", pNameWithTag) |
6345208b |
assert.NilError(c, err) |
90bb2cdb |
out, _, err = dockerCmdWithError("plugin", "remove", pNameWithTag) |
6345208b |
assert.NilError(c, err) |
98f2638f |
assert.Assert(c, strings.Contains(out, pNameWithTag)) |
90bb2cdb |
} |
88fcdb0a |
// Test case for 29185 |
1d92789b |
func (s *DockerSuite) TestInspectUnknownObject(c *testing.T) { |
88fcdb0a |
// This test should work on both Windows and Linux
out, _, err := dockerCmdWithError("inspect", "foobar") |
6345208b |
assert.ErrorContains(c, err, "") |
98f2638f |
assert.Assert(c, strings.Contains(out, "Error: No such object: foobar")) |
6345208b |
assert.ErrorContains(c, err, "Error: No such object: foobar") |
88fcdb0a |
} |