github.com/containers/libpod@v1.9.4-0.20220419124438-4284fd425507/test/e2e/untag_test.go (about)

     1  package integration
     2  
     3  import (
     4  	"os"
     5  
     6  	. "github.com/containers/libpod/test/utils"
     7  	. "github.com/onsi/ginkgo"
     8  	. "github.com/onsi/gomega"
     9  )
    10  
    11  var _ = Describe("Podman untag", func() {
    12  	var (
    13  		tempdir    string
    14  		err        error
    15  		podmanTest *PodmanTestIntegration
    16  	)
    17  
    18  	BeforeEach(func() {
    19  		tempdir, err = CreateTempDirInTempDir()
    20  		if err != nil {
    21  			os.Exit(1)
    22  		}
    23  		podmanTest = PodmanTestCreate(tempdir)
    24  		podmanTest.Setup()
    25  		podmanTest.RestoreAllArtifacts()
    26  
    27  		for _, tag := range []string{"test", "foo", "bar"} {
    28  			session := podmanTest.PodmanNoCache([]string{"tag", ALPINE, tag})
    29  			session.WaitWithDefaultTimeout()
    30  			Expect(session.ExitCode()).To(Equal(0))
    31  		}
    32  
    33  	})
    34  
    35  	AfterEach(func() {
    36  		podmanTest.Cleanup()
    37  		f := CurrentGinkgoTestDescription()
    38  		processTestResult(f)
    39  
    40  	})
    41  
    42  	It("podman untag all", func() {
    43  		session := podmanTest.PodmanNoCache([]string{"untag", ALPINE})
    44  		session.WaitWithDefaultTimeout()
    45  		Expect(session.ExitCode()).To(Equal(0))
    46  
    47  		results := podmanTest.PodmanNoCache([]string{"images", ALPINE})
    48  		results.WaitWithDefaultTimeout()
    49  		Expect(results.ExitCode()).To(Equal(0))
    50  		Expect(results.OutputToStringArray()).To(HaveLen(1))
    51  	})
    52  
    53  	It("podman untag single", func() {
    54  		session := podmanTest.PodmanNoCache([]string{"untag", ALPINE, "localhost/test:latest"})
    55  		session.WaitWithDefaultTimeout()
    56  		Expect(session.ExitCode()).To(Equal(0))
    57  
    58  		results := podmanTest.PodmanNoCache([]string{"images"})
    59  		results.WaitWithDefaultTimeout()
    60  		Expect(results.ExitCode()).To(Equal(0))
    61  		Expect(results.OutputToStringArray()).To(HaveLen(5))
    62  		Expect(results.LineInOuputStartsWith("docker.io/library/alpine")).To(BeTrue())
    63  		Expect(results.LineInOuputStartsWith("localhost/foo")).To(BeTrue())
    64  		Expect(results.LineInOuputStartsWith("localhost/bar")).To(BeTrue())
    65  		Expect(results.LineInOuputStartsWith("localhost/test")).To(BeFalse())
    66  	})
    67  
    68  	It("podman untag not enough arguments", func() {
    69  		session := podmanTest.PodmanNoCache([]string{"untag"})
    70  		session.WaitWithDefaultTimeout()
    71  		Expect(session.ExitCode()).NotTo(Equal(0))
    72  	})
    73  })