Skip to content

Commit f9bb6bf

Browse files
Merge pull request #20090 from wozniakjan/test/extended/speedup_contextdir
extended tests: use leaner repo for contextdir test
2 parents 712df54 + f12e0fc commit f9bb6bf

File tree

4 files changed

+19
-12
lines changed

4 files changed

+19
-12
lines changed

test/extended/builds/contextdir.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,20 @@ var _ = g.Describe("[Feature:Builds][Slow] builds with a context directory", fun
9898

9999
g.Describe("docker context directory build", func() {
100100
g.It(fmt.Sprintf("should docker build an application using a context directory"), func() {
101+
g.By("initializing local repo")
102+
repo, err := exutil.NewGitRepo("contextdir")
103+
o.Expect(err).NotTo(o.HaveOccurred())
104+
defer repo.Remove()
105+
err = repo.AddAndCommit("2.3/Dockerfile", "FROM busybox")
106+
o.Expect(err).NotTo(o.HaveOccurred())
101107

102108
exutil.CheckOpenShiftNamespaceImageStreams(oc)
103109
g.By(fmt.Sprintf("calling oc create -f %q", appFixture))
104-
err := oc.Run("create").Args("-f", appFixture).Execute()
110+
err = oc.Run("create").Args("-f", appFixture).Execute()
105111
o.Expect(err).NotTo(o.HaveOccurred())
106112

107113
g.By("starting a build")
108-
err = oc.Run("start-build").Args(dockerBuildConfigName).Execute()
114+
err = oc.Run("start-build").Args(dockerBuildConfigName, "--from-repo", repo.RepoPath).Execute()
109115
o.Expect(err).NotTo(o.HaveOccurred())
110116

111117
// build will fail if we don't use the right context dir because there won't be a dockerfile present.

test/extended/testdata/bindata.go

+4-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/extended/testdata/builds/test-context-build.json

+3-5
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@
1212
"spec": {
1313
"triggers": [],
1414
"source": {
15-
"type": "Git",
16-
"git": {
17-
"uri":"https://github.com/sclorg/s2i-ruby-container"
18-
},
15+
"type": "binary",
16+
"binary": {},
1917
"contextDir": "2.3"
2018
},
2119
"strategy": {
@@ -152,4 +150,4 @@
152150
}
153151
}
154152
]
155-
}
153+
}

test/extended/util/framework.go

+4
Original file line numberDiff line numberDiff line change
@@ -1327,6 +1327,10 @@ type GitRepo struct {
13271327

13281328
// AddAndCommit commits a file with its content to local repo
13291329
func (r GitRepo) AddAndCommit(file, content string) error {
1330+
dir := filepath.Dir(file)
1331+
if err := os.MkdirAll(filepath.Join(r.RepoPath, dir), 0777); err != nil {
1332+
return err
1333+
}
13301334
if err := ioutil.WriteFile(filepath.Join(r.RepoPath, file), []byte(content), 0666); err != nil {
13311335
return err
13321336
}

0 commit comments

Comments
 (0)