github.com/AbhinandanKurakure/podman/v3@v3.4.10/test/e2e/version_test.go (about) 1 package integration 2 3 import ( 4 "fmt" 5 "os" 6 7 . "github.com/containers/podman/v3/test/utils" 8 "github.com/containers/podman/v3/version" 9 . "github.com/onsi/ginkgo" 10 . "github.com/onsi/gomega" 11 . "github.com/onsi/gomega/gexec" 12 ) 13 14 var _ = Describe("Podman version", func() { 15 var ( 16 tempdir string 17 err error 18 podmanTest *PodmanTestIntegration 19 ) 20 21 BeforeEach(func() { 22 tempdir, err = CreateTempDirInTempDir() 23 if err != nil { 24 os.Exit(1) 25 } 26 podmanTest = PodmanTestCreate(tempdir) 27 }) 28 29 AfterEach(func() { 30 podmanTest.Cleanup() 31 f := CurrentGinkgoTestDescription() 32 processTestResult(f) 33 podmanTest.SeedImages() 34 }) 35 36 It("podman version", func() { 37 session := podmanTest.Podman([]string{"version"}) 38 session.WaitWithDefaultTimeout() 39 Expect(session).Should(Exit(0)) 40 Expect(session.Out.Contents()).Should(ContainSubstring(version.Version.String())) 41 }) 42 43 It("podman -v", func() { 44 session := podmanTest.Podman([]string{"-v"}) 45 session.WaitWithDefaultTimeout() 46 Expect(session).Should(Exit(0)) 47 Expect(session.Out.Contents()).Should(ContainSubstring(version.Version.String())) 48 }) 49 50 It("podman --version", func() { 51 session := podmanTest.Podman([]string{"--version"}) 52 session.WaitWithDefaultTimeout() 53 Expect(session).Should(Exit(0)) 54 Expect(session.Out.Contents()).Should(ContainSubstring(version.Version.String())) 55 }) 56 57 It("podman version --format json", func() { 58 tests := []struct { 59 input string 60 success bool 61 exitCode int 62 }{ 63 {"json", true, 0}, 64 {" json", true, 0}, 65 {"json ", true, 0}, 66 {" json ", true, 0}, 67 {"{{json .}}", true, 0}, 68 {"{{ json .}}", true, 0}, 69 {"{{json . }}", true, 0}, 70 {" {{ json . }} ", true, 0}, 71 {"{{json }}", true, 0}, 72 {"{{json .", false, 125}, 73 {"json . }}", false, 0}, // without opening {{ template seen as string literal 74 } 75 for _, tt := range tests { 76 session := podmanTest.Podman([]string{"version", "--format", tt.input}) 77 session.WaitWithDefaultTimeout() 78 79 desc := fmt.Sprintf("JSON test(%q)", tt.input) 80 Expect(session).Should(Exit(tt.exitCode), desc) 81 Expect(session.IsJSONOutputValid()).To(Equal(tt.success), desc) 82 } 83 }) 84 85 It("podman version --format GO template", func() { 86 session := podmanTest.Podman([]string{"version", "--format", "{{ .Client.Version }}"}) 87 session.WaitWithDefaultTimeout() 88 Expect(session).Should(Exit(0)) 89 90 session = podmanTest.Podman([]string{"version", "--format", "{{ .Server.Version }}"}) 91 session.WaitWithDefaultTimeout() 92 Expect(session).Should(Exit(0)) 93 94 session = podmanTest.Podman([]string{"version", "--format", "{{ .Version }}"}) 95 session.WaitWithDefaultTimeout() 96 Expect(session).Should(Exit(0)) 97 }) 98 99 It("podman help", func() { 100 session := podmanTest.Podman([]string{"help"}) 101 session.WaitWithDefaultTimeout() 102 Expect(session).Should(Exit(0)) 103 Expect(session.Out.Contents()).Should( 104 ContainSubstring("Display the Podman version information"), 105 ) 106 }) 107 })