mirror of
https://github.com/containers/podman.git
synced 2025-08-06 11:32:07 +08:00
Fixes podman pod create --pod-id-file #6292
Prints pod id to file and adds relevant test case Signed-off-by: Sujil02 <sushah@redhat.com>
This commit is contained in:
@ -2,7 +2,9 @@ package integration
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
. "github.com/containers/libpod/test/utils"
|
||||
@ -284,4 +286,26 @@ var _ = Describe("Podman pod create", func() {
|
||||
podCreate.WaitWithDefaultTimeout()
|
||||
Expect(podCreate.ExitCode()).To(Equal(125))
|
||||
})
|
||||
|
||||
It("podman create pod and print id to external file", func() {
|
||||
// Switch to temp dir and restore it afterwards
|
||||
cwd, err := os.Getwd()
|
||||
Expect(err).To(BeNil())
|
||||
Expect(os.Chdir(os.TempDir())).To(BeNil())
|
||||
targetPath := filepath.Join(os.TempDir(), "dir")
|
||||
Expect(os.MkdirAll(targetPath, 0755)).To(BeNil())
|
||||
targetFile := filepath.Join(targetPath, "idFile")
|
||||
defer Expect(os.RemoveAll(targetFile)).To(BeNil())
|
||||
defer Expect(os.Chdir(cwd)).To(BeNil())
|
||||
|
||||
session := podmanTest.Podman([]string{"pod", "create", "--name=abc", "--pod-id-file", targetFile})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session.ExitCode()).To(Equal(0))
|
||||
|
||||
id, _ := ioutil.ReadFile(targetFile)
|
||||
check := podmanTest.Podman([]string{"pod", "inspect", "abc"})
|
||||
check.WaitWithDefaultTimeout()
|
||||
data := check.InspectPodToJSON()
|
||||
Expect(data.ID).To(Equal(string(id)))
|
||||
})
|
||||
})
|
||||
|
Reference in New Issue
Block a user