podman inspect: fix error difference between local and remote

There is no reason for local and rmeote to use a different error that
just differs in quoting. Make them consitent to simplify the tests.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
Paul Holzinger 2025-07-15 16:49:31 +02:00
parent 4364db989a
commit 8b1f06bf8f
No known key found for this signature in database
GPG Key ID: EB145DD938A3CAF2
3 changed files with 5 additions and 13 deletions

View File

@ -539,7 +539,7 @@ func (ic *ContainerEngine) ContainerInspect(ctx context.Context, namesOrIds []st
// ErrNoSuchCtr is non-fatal, other errors will be
// treated as fatal.
if errors.Is(err, define.ErrNoSuchCtr) {
errs = append(errs, fmt.Errorf("no such container %s", name))
errs = append(errs, fmt.Errorf("no such container %q", name))
continue
}
return nil, nil, err
@ -550,7 +550,7 @@ func (ic *ContainerEngine) ContainerInspect(ctx context.Context, namesOrIds []st
// ErrNoSuchCtr is non-fatal, other errors will be
// treated as fatal.
if errors.Is(err, define.ErrNoSuchCtr) {
errs = append(errs, fmt.Errorf("no such container %s", name))
errs = append(errs, fmt.Errorf("no such container %q", name))
continue
}
return nil, nil, err

View File

@ -188,11 +188,7 @@ var _ = Describe("Podman inspect", func() {
ctrInspect := podmanTest.Podman([]string{"container", "inspect", ALPINE})
ctrInspect.WaitWithDefaultTimeout()
if IsRemote() {
Expect(ctrInspect).To(ExitWithError(125, fmt.Sprintf("no such container %q", ALPINE)))
} else {
Expect(ctrInspect).To(ExitWithError(125, fmt.Sprintf("no such container %s", ALPINE)))
}
Expect(ctrInspect).To(ExitWithError(125, fmt.Sprintf("no such container %q", ALPINE)))
imageInspect := podmanTest.Podman([]string{"image", "inspect", ALPINE})
imageInspect.WaitWithDefaultTimeout()
@ -399,11 +395,7 @@ var _ = Describe("Podman inspect", func() {
inspect := podmanTest.Podman([]string{"inspect", "--type", "container", podName})
inspect.WaitWithDefaultTimeout()
if IsRemote() {
Expect(inspect).To(ExitWithError(125, fmt.Sprintf("no such container %q", podName)))
} else {
Expect(inspect).To(ExitWithError(125, fmt.Sprintf("no such container %s", podName)))
}
Expect(inspect).To(ExitWithError(125, fmt.Sprintf("no such container %q", podName)))
})
It("podman inspect --type network on a container should fail", func() {

View File

@ -1081,7 +1081,7 @@ EOF
is "$output" "$exit_code_prop" \
"$basename: service container has the expected policy set in its annotations"
else
assert "$output" =~ "no such container $service_container" \
assert "$output" =~ "no such container \"$service_container\"" \
"$basename: unexpected error from podman container inspect"
fi