github.com/containers/podman/v5@v5.1.0-rc1/test/e2e/history_test.go (about) 1 package integration 2 3 import ( 4 . "github.com/containers/podman/v5/test/utils" 5 . "github.com/onsi/ginkgo/v2" 6 . "github.com/onsi/gomega" 7 ) 8 9 var _ = Describe("Podman history", func() { 10 11 It("podman history output flag", func() { 12 session := podmanTest.Podman([]string{"history", ALPINE}) 13 session.WaitWithDefaultTimeout() 14 Expect(session).Should(ExitCleanly()) 15 Expect(session.OutputToStringArray()).ToNot(BeEmpty()) 16 }) 17 18 It("podman history with GO template", func() { 19 session := podmanTest.Podman([]string{"history", "--format", "{{.ID}} {{.Created}}", ALPINE}) 20 session.WaitWithDefaultTimeout() 21 Expect(session).Should(ExitCleanly()) 22 Expect(session.OutputToStringArray()).ToNot(BeEmpty()) 23 24 session = podmanTest.Podman([]string{"history", "--format", "{{.CreatedAt}};{{.Size}}", ALPINE}) 25 session.WaitWithDefaultTimeout() 26 Expect(session).Should(ExitCleanly()) 27 Expect(session.OutputToString()).To(MatchRegexp("[0-9-]{10}T[0-9:]{8}[Z0-9+:-]+;[0-9.]+[MG]*B( .+)?")) 28 }) 29 30 It("podman history with human flag", func() { 31 session := podmanTest.Podman([]string{"history", "--human=false", ALPINE}) 32 session.WaitWithDefaultTimeout() 33 Expect(session).Should(ExitCleanly()) 34 Expect(session.OutputToStringArray()).ToNot(BeEmpty()) 35 }) 36 37 It("podman history with quiet flag", func() { 38 session := podmanTest.Podman([]string{"history", "-qH", ALPINE}) 39 session.WaitWithDefaultTimeout() 40 Expect(session).Should(ExitCleanly()) 41 Expect(session.OutputToStringArray()).ToNot(BeEmpty()) 42 }) 43 44 It("podman history with no-trunc flag", func() { 45 session := podmanTest.Podman([]string{"history", "--no-trunc", ALPINE}) 46 session.WaitWithDefaultTimeout() 47 Expect(session).Should(ExitCleanly()) 48 Expect(session.OutputToStringArray()).ToNot(BeEmpty()) 49 50 session = podmanTest.Podman([]string{"history", "--no-trunc", "--format", "{{.ID}}", ALPINE}) 51 session.WaitWithDefaultTimeout() 52 Expect(session).Should(ExitCleanly()) 53 lines := session.OutputToStringArray() 54 Expect(lines).ToNot(BeEmpty()) 55 // the image id must be 64 chars long 56 Expect(lines[0]).To(HaveLen(64)) 57 58 session = podmanTest.Podman([]string{"history", "--no-trunc", "--format", "{{.CreatedBy}}", ALPINE}) 59 session.WaitWithDefaultTimeout() 60 Expect(session).Should(ExitCleanly()) 61 lines = session.OutputToStringArray() 62 Expect(lines).ToNot(BeEmpty()) 63 Expect(session.OutputToString()).ToNot(ContainSubstring("...")) 64 // the second line in the alpine history contains a command longer than 45 chars 65 Expect(len(lines[1])).To(BeNumerically(">", 45)) 66 67 session = podmanTest.Podman([]string{"history", "--no-trunc", "--format", "{{.Size}}", ALPINE}) 68 session.WaitWithDefaultTimeout() 69 Expect(session).Should(ExitCleanly()) 70 Expect(session.OutputToStringArray()).To(Equal([]string{"0B", "5.84MB"})) 71 }) 72 73 It("podman history with json flag", func() { 74 session := podmanTest.Podman([]string{"history", "--format=json", ALPINE}) 75 session.WaitWithDefaultTimeout() 76 Expect(session).Should(ExitCleanly()) 77 Expect(session.OutputToString()).To(BeValidJSON()) 78 }) 79 })