summaryrefslogtreecommitdiff
path: root/pkg/systemd/generate/pods_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/systemd/generate/pods_test.go')
-rw-r--r--pkg/systemd/generate/pods_test.go49
1 files changed, 47 insertions, 2 deletions
diff --git a/pkg/systemd/generate/pods_test.go b/pkg/systemd/generate/pods_test.go
index f6e225c35..f7ce33a30 100644
--- a/pkg/systemd/generate/pods_test.go
+++ b/pkg/systemd/generate/pods_test.go
@@ -36,7 +36,7 @@ func TestValidateRestartPolicyPod(t *testing.T) {
}
func TestCreatePodSystemdUnit(t *testing.T) {
- podGoodName := `# pod-123abc.service
+ podGood := `# pod-123abc.service
# autogenerated by Podman CI
[Unit]
@@ -59,10 +59,37 @@ Type=forking
[Install]
WantedBy=multi-user.target default.target`
+ podGoodNamedNew := `# pod-123abc.service
+# autogenerated by Podman CI
+
+[Unit]
+Description=Podman pod-123abc.service
+Documentation=man:podman-generate-systemd(1)
+Wants=network.target
+After=network-online.target
+Requires=container-1.service container-2.service
+Before=container-1.service container-2.service
+
+[Service]
+Environment=PODMAN_SYSTEMD_UNIT=%n
+Restart=on-failure
+ExecStartPre=/usr/bin/rm -f %t/pod-123abc.pid %t/pod-123abc.pod-id
+ExecStartPre=/usr/bin/podman pod create --infra-conmon-pidfile %t/pod-123abc.pid --pod-id-file %t/pod-123abc.pod-id --name foo --replace
+ExecStart=/usr/bin/podman pod start --pod-id-file %t/pod-123abc.pod-id
+ExecStop=/usr/bin/podman pod stop --ignore --pod-id-file %t/pod-123abc.pod-id -t 10
+ExecStopPost=/usr/bin/podman pod rm --ignore -f --pod-id-file %t/pod-123abc.pod-id
+PIDFile=%t/pod-123abc.pid
+KillMode=none
+Type=forking
+
+[Install]
+WantedBy=multi-user.target default.target`
+
tests := []struct {
name string
info podInfo
want string
+ new bool
wantErr bool
}{
{"pod",
@@ -76,7 +103,24 @@ WantedBy=multi-user.target default.target`
PodmanVersion: "CI",
RequiredServices: []string{"container-1", "container-2"},
},
- podGoodName,
+ podGood,
+ false,
+ false,
+ },
+ {"pod --new",
+ podInfo{
+ Executable: "/usr/bin/podman",
+ ServiceName: "pod-123abc",
+ InfraNameOrID: "jadda-jadda-infra",
+ RestartPolicy: "on-failure",
+ PIDFile: "/var/run/containers/storage/overlay-containers/639c53578af4d84b8800b4635fa4e680ee80fd67e0e6a2d4eea48d1e3230f401/userdata/conmon.pid",
+ StopTimeout: 10,
+ PodmanVersion: "CI",
+ RequiredServices: []string{"container-1", "container-2"},
+ CreateCommand: []string{"podman", "pod", "create", "--name", "foo"},
+ },
+ podGoodNamedNew,
+ true,
false,
},
}
@@ -86,6 +130,7 @@ WantedBy=multi-user.target default.target`
t.Run(tt.name, func(t *testing.T) {
opts := entities.GenerateSystemdOptions{
Files: false,
+ New: test.new,
}
got, err := executePodTemplate(&test.info, opts)
if (err != nil) != test.wantErr {