Add a test for image_resource version
concourse/atc#190
@@ -46,7 +46,14 @@ ls /bin
)
Expect(err).NotTo(HaveOccurred())
- err = ioutil.WriteFile(
+ })
+
+ AfterEach(func() {
+ os.RemoveAll(tmpdir)
+ })
+
+ It("propagates the rootfs and metadata to the task", func() {
+ err := ioutil.WriteFile(
filepath.Join(fixture, "task.yml"),
[]byte(`---
platform: linux
@@ -69,21 +76,64 @@ run:
0644,
)
Expect(err).NotTo(HaveOccurred())
- })
+ fly := exec.Command(flyBin, "-t", targetedConcourse, "execute", "-c", "task.yml")
+ fly.Dir = fixture
- AfterEach(func() {
- os.RemoveAll(tmpdir)
+ session := helpers.StartFly(fly)
+
+ Eventually(session).Should(gexec.Exit(0))
+
+ Expect(session).To(gbytes.Say("/hello-im-a-git-rootfs"))
+ Expect(session).To(gbytes.Say("hello-im-image-provided-env"))
})
- It("propagates the rootfs and metadata to the task", func() {
+ It("allows a version to be specified", func() {
+ createFixture := func(ref string) {
+ err := ioutil.WriteFile(
+ filepath.Join(fixture, "task.yml"),
+ []byte(`---
+platform: linux
+
+image_resource:
+ type: git
+ source: {uri: "`+rootfsGitServer.URI()+`"}
+ version: { ref: "`+ref+`"}
+
+inputs:
+- name: fixture
+
+run:
+ path: sh
+ args:
+ - -c
+ - |
+ touch /some-file.txt && cat /some-file.txt
+`),
+ 0644,
+ )
+ Expect(err).NotTo(HaveOccurred())
+ }
+
+ oldRef := rootfsGitServer.RevParse("master")
+ rootfsGitServer.CommitFileToBranch("hello, world", "rootfs/some-file.txt", "master")
+ newRef := rootfsGitServer.RevParse("master")
+
+ createFixture(oldRef)
fly := exec.Command(flyBin, "-t", targetedConcourse, "execute", "-c", "task.yml")
fly.Dir = fixture
session := helpers.StartFly(fly)
Eventually(session).Should(gexec.Exit(0))
+ Expect(session).ToNot(gbytes.Say("hello, world"))
- Expect(session).To(gbytes.Say("/hello-im-a-git-rootfs"))
- Expect(session).To(gbytes.Say("hello-im-image-provided-env"))
+ createFixture(newRef)
+ fly = exec.Command(flyBin, "-t", targetedConcourse, "execute", "-c", "task.yml")
+ fly.Dir = fixture
+
+ session = helpers.StartFly(fly)
+
+ Eventually(session).Should(gexec.Exit(0))
+ Expect(session).To(gbytes.Say("hello, world"))
})
})
