github.com/dmaizel/tests@v0.0.0-20210728163746-cae6a2d9cee8/integration/docker/export_test.go (about) 1 // Copyright (c) 2018 Intel Corporation 2 // 3 // SPDX-License-Identifier: Apache-2.0 4 5 package docker 6 7 import ( 8 "io/ioutil" 9 "os" 10 11 . "github.com/onsi/ginkgo" 12 . "github.com/onsi/gomega" 13 ) 14 15 var _ = Describe("export", func() { 16 var ( 17 id string 18 exitCode int 19 ) 20 21 BeforeEach(func() { 22 id = randomDockerName() 23 _, _, exitCode = dockerRun("-td", "--name", id, Image) 24 Expect(exitCode).To(Equal(0)) 25 }) 26 27 AfterEach(func() { 28 Expect(RemoveDockerContainer(id)).To(BeTrue()) 29 Expect(ExistDockerContainer(id)).NotTo(BeTrue()) 30 }) 31 32 Describe("export with docker", func() { 33 Context("export a container", func() { 34 It("should export filesystem as a tar archive", func() { 35 file, err := ioutil.TempFile(os.TempDir(), "latest.tar") 36 Expect(err).ToNot(HaveOccurred()) 37 defer os.Remove(file.Name()) 38 _, _, exitCode = dockerExport("--output", file.Name(), id) 39 Expect(exitCode).To(Equal(0)) 40 Expect(file.Name()).To(BeAnExistingFile()) 41 fileInfo, err := file.Stat() 42 Expect(err).ToNot(HaveOccurred()) 43 Expect(fileInfo.Size).NotTo(Equal(0)) 44 err = file.Close() 45 Expect(err).ToNot(HaveOccurred()) 46 }) 47 }) 48 }) 49 })