github.com/containers/podman/v4@v4.9.4/test/e2e/untag_test.go (about) 1 package integration 2 3 import ( 4 . "github.com/containers/podman/v4/test/utils" 5 . "github.com/onsi/ginkgo/v2" 6 . "github.com/onsi/gomega" 7 . "github.com/onsi/gomega/gexec" 8 ) 9 10 var _ = Describe("Podman untag", func() { 11 12 It("podman untag all", func() { 13 podmanTest.AddImageToRWStore(CIRROS_IMAGE) 14 tags := []string{CIRROS_IMAGE, "registry.com/foo:bar", "localhost/foo:bar"} 15 16 cmd := []string{"tag"} 17 cmd = append(cmd, tags...) 18 session := podmanTest.Podman(cmd) 19 session.WaitWithDefaultTimeout() 20 Expect(session).Should(ExitCleanly()) 21 22 // Make sure that all tags exists. 23 for _, t := range tags { 24 session = podmanTest.Podman([]string{"image", "exists", t}) 25 session.WaitWithDefaultTimeout() 26 Expect(session).Should(ExitCleanly()) 27 } 28 29 // No arguments -> remove all tags. 30 session = podmanTest.Podman([]string{"untag", CIRROS_IMAGE}) 31 session.WaitWithDefaultTimeout() 32 Expect(session).Should(ExitCleanly()) 33 34 // Make sure that none of tags exists anymore. 35 for _, t := range tags { 36 session = podmanTest.Podman([]string{"image", "exists", t}) 37 session.WaitWithDefaultTimeout() 38 Expect(session).Should(Exit(1)) 39 } 40 }) 41 42 It("podman tag/untag - tag normalization", func() { 43 podmanTest.AddImageToRWStore(CIRROS_IMAGE) 44 45 tests := []struct { 46 tag, normalized string 47 }{ 48 {"registry.com/image:latest", "registry.com/image:latest"}, 49 {"registry.com/image", "registry.com/image:latest"}, 50 {"image:latest", "localhost/image:latest"}, 51 {"image", "localhost/image:latest"}, 52 } 53 54 // Make sure that the user input is normalized correctly for 55 // `podman tag` and `podman untag`. 56 for _, tt := range tests { 57 session := podmanTest.Podman([]string{"tag", CIRROS_IMAGE, tt.tag}) 58 session.WaitWithDefaultTimeout() 59 Expect(session).Should(ExitCleanly()) 60 61 session = podmanTest.Podman([]string{"image", "exists", tt.normalized}) 62 session.WaitWithDefaultTimeout() 63 Expect(session).Should(ExitCleanly()) 64 65 session = podmanTest.Podman([]string{"untag", CIRROS_IMAGE, tt.tag}) 66 session.WaitWithDefaultTimeout() 67 Expect(session).Should(ExitCleanly()) 68 69 session = podmanTest.Podman([]string{"image", "exists", tt.normalized}) 70 session.WaitWithDefaultTimeout() 71 Expect(session).Should(Exit(1)) 72 } 73 }) 74 75 })