summaryrefslogtreecommitdiff
path: root/test/e2e/build_test.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-02-05 07:13:32 -0800
committerGitHub <noreply@github.com>2020-02-05 07:13:32 -0800
commit107fd64970faa5870a4c23c971f5061e57b99067 (patch)
treee0edb163058d8d0237d488f0c1292692e5bfb8d4 /test/e2e/build_test.go
parentfb8c49479e33c01b0c97cf6286255c39415e6bc6 (diff)
parent56a9c6ae57f9decba4944fbebd469ca43b003a2f (diff)
downloadpodman-107fd64970faa5870a4c23c971f5061e57b99067.tar.gz
podman-107fd64970faa5870a4c23c971f5061e57b99067.tar.bz2
podman-107fd64970faa5870a4c23c971f5061e57b99067.zip
Merge pull request #5090 from openSUSE/containerfile-location-test
Add Containerfile location e2e test
Diffstat (limited to 'test/e2e/build_test.go')
-rw-r--r--test/e2e/build_test.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/test/e2e/build_test.go b/test/e2e/build_test.go
index 71f5d1b02..b4e400549 100644
--- a/test/e2e/build_test.go
+++ b/test/e2e/build_test.go
@@ -3,7 +3,9 @@
package integration
import (
+ "io/ioutil"
"os"
+ "path/filepath"
"strings"
. "github.com/containers/libpod/test/utils"
@@ -105,4 +107,39 @@ var _ = Describe("Podman build", func() {
session.WaitWithDefaultTimeout()
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"))
+ })
})