mirror of
https://github.com/containers/podman.git
synced 2025-06-23 02:18:13 +08:00
Merge pull request #5090 from openSUSE/containerfile-location-test
Add Containerfile location e2e test
This commit is contained in:
@ -3,7 +3,9 @@
|
|||||||
package integration
|
package integration
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
. "github.com/containers/libpod/test/utils"
|
. "github.com/containers/libpod/test/utils"
|
||||||
@ -105,4 +107,39 @@ var _ = Describe("Podman build", func() {
|
|||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session.ExitCode()).To(Equal(0))
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("podman build Containerfile locations", func() {
|
||||||
|
// Given
|
||||||
|
// Switch to temp dir and restore it afterwards
|
||||||
|
cwd, err := os.Getwd()
|
||||||
|
Expect(err).To(BeNil())
|
||||||
|
Expect(os.Chdir(os.TempDir())).To(BeNil())
|
||||||
|
defer Expect(os.Chdir(cwd)).To(BeNil())
|
||||||
|
|
||||||
|
// Write target and fake files
|
||||||
|
targetPath := filepath.Join(os.TempDir(), "dir")
|
||||||
|
Expect(os.MkdirAll(targetPath, 0755)).To(BeNil())
|
||||||
|
|
||||||
|
fakeFile := filepath.Join(os.TempDir(), "Containerfile")
|
||||||
|
Expect(ioutil.WriteFile(fakeFile, []byte("FROM alpine"), 0755)).To(BeNil())
|
||||||
|
|
||||||
|
targetFile := filepath.Join(targetPath, "Containerfile")
|
||||||
|
Expect(ioutil.WriteFile(targetFile, []byte("FROM scratch"), 0755)).To(BeNil())
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
Expect(os.RemoveAll(fakeFile)).To(BeNil())
|
||||||
|
Expect(os.RemoveAll(targetFile)).To(BeNil())
|
||||||
|
}()
|
||||||
|
|
||||||
|
// When
|
||||||
|
session := podmanTest.PodmanNoCache([]string{
|
||||||
|
"build", "-f", targetFile, "-t", "test-locations",
|
||||||
|
})
|
||||||
|
session.WaitWithDefaultTimeout()
|
||||||
|
|
||||||
|
// Then
|
||||||
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
|
Expect(strings.Fields(session.OutputToString())).
|
||||||
|
To(ContainElement("scratch"))
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user