summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pkg/domain/infra/abi/generate.go5
-rw-r--r--test/e2e/generate_systemd_test.go12
2 files changed, 15 insertions, 2 deletions
diff --git a/pkg/domain/infra/abi/generate.go b/pkg/domain/infra/abi/generate.go
index 93c4ede49..0b73ddd7e 100644
--- a/pkg/domain/infra/abi/generate.go
+++ b/pkg/domain/infra/abi/generate.go
@@ -20,9 +20,10 @@ func (ic *ContainerEngine) GenerateSystemd(ctx context.Context, nameOrID string,
if ctrErr == nil {
// Generate the unit for the container.
s, err := generate.ContainerUnit(ctr, options)
- if err == nil {
- return &entities.GenerateSystemdReport{Output: s}, nil
+ if err != nil {
+ return nil, err
}
+ return &entities.GenerateSystemdReport{Output: s}, nil
}
// If it's not a container, we either have a pod or garbage.
diff --git a/test/e2e/generate_systemd_test.go b/test/e2e/generate_systemd_test.go
index d114744c4..60d9162d1 100644
--- a/test/e2e/generate_systemd_test.go
+++ b/test/e2e/generate_systemd_test.go
@@ -53,6 +53,18 @@ var _ = Describe("Podman generate systemd", func() {
Expect(session).To(ExitWithError())
})
+ It("podman generate systemd bad restart-policy value", func() {
+ session := podmanTest.Podman([]string{"create", "--name", "foobar", "alpine", "top"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ session = podmanTest.Podman([]string{"generate", "systemd", "--restart-policy", "bogus", "foobar"})
+ session.WaitWithDefaultTimeout()
+ Expect(session).To(ExitWithError())
+ found, _ := session.ErrorGrepString("Error: bogus is not a valid restart policy")
+ Expect(found).Should(BeTrue())
+ })
+
It("podman generate systemd good timeout value", func() {
session := podmanTest.Podman([]string{"create", "--name", "foobar", "alpine", "top"})
session.WaitWithDefaultTimeout()