fly,testflight: add --async and --shallow for check resource/type
Signed-off-by: Rui Yang <ryang@pivotal.io>
This commit is contained in:
parent
e66e0302be
commit
69f70afc8b
|
@ -16,8 +16,8 @@ import (
|
|||
type CheckResourceCommand struct {
|
||||
Resource flaghelpers.ResourceFlag `short:"r" long:"resource" required:"true" value-name:"PIPELINE/RESOURCE" description:"Name of a resource to check version for"`
|
||||
Version *atc.Version `short:"f" long:"from" value-name:"VERSION" description:"Version of the resource to check from, e.g. ref:abcd or path:thing-1.2.3.tgz"`
|
||||
Watch bool `short:"w" long:"watch" value-name:"WATCH" description:"Watch for the status of the check to succeed/fail"`
|
||||
Recursive bool `long:"recursive" value-name:"RECURSIVE" description:"Check and wait for versions of all parent types"`
|
||||
Async bool `short:"a" long:"async" value-name:"ASYNC" description:"Return the check without waiting for its result"`
|
||||
Shallow bool `long:"shallow" value-name:"SHALLOW" description:"Check the resource itself only"`
|
||||
}
|
||||
|
||||
func (command *CheckResourceCommand) Execute(args []string) error {
|
||||
|
@ -36,7 +36,7 @@ func (command *CheckResourceCommand) Execute(args []string) error {
|
|||
version = *command.Version
|
||||
}
|
||||
|
||||
if command.Recursive {
|
||||
if !command.Shallow {
|
||||
err = command.checkParent(target)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -54,7 +54,7 @@ func (command *CheckResourceCommand) Execute(args []string) error {
|
|||
|
||||
var checkID = strconv.Itoa(check.ID)
|
||||
|
||||
if command.Watch {
|
||||
if !command.Async {
|
||||
for check.Status == "started" {
|
||||
time.Sleep(time.Second)
|
||||
|
||||
|
@ -125,8 +125,6 @@ func (command *CheckResourceCommand) checkParent(target rc.Target) error {
|
|||
ResourceName: parentType.Name,
|
||||
PipelineName: command.Resource.PipelineName,
|
||||
},
|
||||
Recursive: true,
|
||||
Watch: true,
|
||||
}
|
||||
|
||||
return cmd.Execute(nil)
|
||||
|
|
|
@ -16,8 +16,8 @@ import (
|
|||
type CheckResourceTypeCommand struct {
|
||||
ResourceType flaghelpers.ResourceFlag `short:"r" long:"resource-type" required:"true" value-name:"PIPELINE/RESOURCE-TYPE" description:"Name of a resource-type to check"`
|
||||
Version *atc.Version `short:"f" long:"from" value-name:"VERSION" description:"Version of the resource type to check from, e.g. digest:sha256@..."`
|
||||
Watch bool `short:"w" long:"watch" value-name:"WATCH" description:"Watch for the status of the check to succeed/fail"`
|
||||
Recursive bool `long:"recursive" value-name:"RECURSIVE" description:"Check and wait for versions of all parent types"`
|
||||
Async bool `short:"a" long:"async" value-name:"ASYNC" description:"Return the check without waiting for its result"`
|
||||
Shallow bool `long:"shallow" value-name:"SHALLOW" description:"Check the resource type itself only"`
|
||||
}
|
||||
|
||||
func (command *CheckResourceTypeCommand) Execute(args []string) error {
|
||||
|
@ -37,7 +37,7 @@ func (command *CheckResourceTypeCommand) Execute(args []string) error {
|
|||
version = *command.Version
|
||||
}
|
||||
|
||||
if command.Recursive {
|
||||
if !command.Shallow {
|
||||
err = command.checkParent(target)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -55,7 +55,7 @@ func (command *CheckResourceTypeCommand) Execute(args []string) error {
|
|||
|
||||
var checkID = strconv.Itoa(check.ID)
|
||||
|
||||
if command.Watch {
|
||||
if !command.Async {
|
||||
for check.Status == "started" {
|
||||
time.Sleep(time.Second)
|
||||
|
||||
|
@ -122,8 +122,6 @@ func (command *CheckResourceTypeCommand) checkParent(target rc.Target) error {
|
|||
ResourceName: parentType.Name,
|
||||
PipelineName: command.ResourceType.PipelineName,
|
||||
},
|
||||
Recursive: true,
|
||||
Watch: true,
|
||||
}
|
||||
|
||||
return cmd.Execute(nil)
|
||||
|
|
|
@ -66,7 +66,7 @@ var _ = Describe("CheckResource", func() {
|
|||
|
||||
It("sends check resource request to ATC", func() {
|
||||
Expect(func() {
|
||||
flyCmd = exec.Command(flyPath, "-t", targetName, "check-resource", "-r", "mypipeline/myresource", "-f", "ref:fake-ref")
|
||||
flyCmd = exec.Command(flyPath, "-t", targetName, "check-resource", "-r", "mypipeline/myresource", "-f", "ref:fake-ref", "-a", "--shallow")
|
||||
sess, err := gexec.Start(flyCmd, GinkgoWriter, GinkgoWriter)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
|
@ -104,7 +104,7 @@ var _ = Describe("CheckResource", func() {
|
|||
|
||||
It("sends check resource request to ATC", func() {
|
||||
Expect(func() {
|
||||
flyCmd = exec.Command(flyPath, "-t", targetName, "check-resource", "-r", "mypipeline/myresource")
|
||||
flyCmd = exec.Command(flyPath, "-t", targetName, "check-resource", "-r", "mypipeline/myresource", "--shallow", "-a")
|
||||
sess, err := gexec.Start(flyCmd, GinkgoWriter, GinkgoWriter)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
|
@ -128,7 +128,7 @@ var _ = Describe("CheckResource", func() {
|
|||
})
|
||||
})
|
||||
|
||||
Context("when watching the check succeed", func() {
|
||||
Context("when the check succeed", func() {
|
||||
BeforeEach(func() {
|
||||
expectedURL := "/api/v1/teams/main/pipelines/mypipeline/resources/myresource/check"
|
||||
atcServer.AppendHandlers(
|
||||
|
@ -152,7 +152,7 @@ var _ = Describe("CheckResource", func() {
|
|||
|
||||
It("sends check resource request to ATC", func() {
|
||||
Expect(func() {
|
||||
flyCmd = exec.Command(flyPath, "-t", targetName, "check-resource", "-r", "mypipeline/myresource", "-w")
|
||||
flyCmd = exec.Command(flyPath, "-t", targetName, "check-resource", "-r", "mypipeline/myresource", "--shallow")
|
||||
sess, err := gexec.Start(flyCmd, GinkgoWriter, GinkgoWriter)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
|
@ -176,7 +176,7 @@ var _ = Describe("CheckResource", func() {
|
|||
})
|
||||
})
|
||||
|
||||
Context("when watching the check fail", func() {
|
||||
Context("when the check fail", func() {
|
||||
BeforeEach(func() {
|
||||
expectedURL := "/api/v1/teams/main/pipelines/mypipeline/resources/myresource/check"
|
||||
atcServer.AppendHandlers(
|
||||
|
@ -201,7 +201,7 @@ var _ = Describe("CheckResource", func() {
|
|||
|
||||
It("sends check resource request to ATC", func() {
|
||||
Expect(func() {
|
||||
flyCmd = exec.Command(flyPath, "-t", targetName, "check-resource", "-r", "mypipeline/myresource", "-w")
|
||||
flyCmd = exec.Command(flyPath, "-t", targetName, "check-resource", "-r", "mypipeline/myresource", "--shallow")
|
||||
sess, err := gexec.Start(flyCmd, GinkgoWriter, GinkgoWriter)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
|
@ -273,7 +273,7 @@ var _ = Describe("CheckResource", func() {
|
|||
|
||||
It("sends check resource request to ATC", func() {
|
||||
Expect(func() {
|
||||
flyCmd = exec.Command(flyPath, "-t", targetName, "check-resource", "-r", "mypipeline/myresource", "--recursive")
|
||||
flyCmd = exec.Command(flyPath, "-t", targetName, "check-resource", "-r", "mypipeline/myresource", "-a")
|
||||
sess, err := gexec.Start(flyCmd, GinkgoWriter, GinkgoWriter)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
|
@ -352,7 +352,7 @@ var _ = Describe("CheckResource", func() {
|
|||
|
||||
It("sends check resource request to ATC", func() {
|
||||
Expect(func() {
|
||||
flyCmd = exec.Command(flyPath, "-t", targetName, "check-resource", "-r", "mypipeline/myresource", "--recursive")
|
||||
flyCmd = exec.Command(flyPath, "-t", targetName, "check-resource", "-r", "mypipeline/myresource")
|
||||
sess, err := gexec.Start(flyCmd, GinkgoWriter, GinkgoWriter)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
|
@ -390,7 +390,7 @@ var _ = Describe("CheckResource", func() {
|
|||
|
||||
It("sends correct check resource request to ATC", func() {
|
||||
Expect(func() {
|
||||
flyCmd = exec.Command(flyPath, "-t", targetName, "check-resource", "-r", "mypipeline/myresource", "-f", "ref1:fake-ref-1", "-f", "ref2:fake-ref-2")
|
||||
flyCmd = exec.Command(flyPath, "-t", targetName, "check-resource", "-r", "mypipeline/myresource", "-f", "ref1:fake-ref-1", "-f", "ref2:fake-ref-2", "--shallow", "-a")
|
||||
sess, err := gexec.Start(flyCmd, GinkgoWriter, GinkgoWriter)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
|
@ -424,7 +424,7 @@ var _ = Describe("CheckResource", func() {
|
|||
})
|
||||
|
||||
It("fails with error", func() {
|
||||
flyCmd = exec.Command(flyPath, "-t", targetName, "check-resource", "-r", "mypipeline/myresource")
|
||||
flyCmd = exec.Command(flyPath, "-t", targetName, "check-resource", "-r", "mypipeline/myresource", "--shallow")
|
||||
sess, err := gexec.Start(flyCmd, GinkgoWriter, GinkgoWriter)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
|
@ -446,7 +446,7 @@ var _ = Describe("CheckResource", func() {
|
|||
})
|
||||
|
||||
It("outputs error in response body", func() {
|
||||
flyCmd = exec.Command(flyPath, "-t", targetName, "check-resource", "-r", "mypipeline/myresource")
|
||||
flyCmd = exec.Command(flyPath, "-t", targetName, "check-resource", "-r", "mypipeline/myresource", "--shallow")
|
||||
sess, err := gexec.Start(flyCmd, GinkgoWriter, GinkgoWriter)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ var _ = Describe("CheckResourceType", func() {
|
|||
|
||||
It("sends check resource request to ATC", func() {
|
||||
Expect(func() {
|
||||
flyCmd = exec.Command(flyPath, "-t", targetName, "check-resource-type", "-r", "mypipeline/myresource", "-f", "ref:fake-ref")
|
||||
flyCmd = exec.Command(flyPath, "-t", targetName, "check-resource-type", "-r", "mypipeline/myresource", "-f", "ref:fake-ref", "--shallow", "-a")
|
||||
sess, err := gexec.Start(flyCmd, GinkgoWriter, GinkgoWriter)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
|
@ -102,7 +102,7 @@ var _ = Describe("CheckResourceType", func() {
|
|||
|
||||
It("sends check resource request to ATC", func() {
|
||||
Expect(func() {
|
||||
flyCmd = exec.Command(flyPath, "-t", targetName, "check-resource-type", "-r", "mypipeline/myresource")
|
||||
flyCmd = exec.Command(flyPath, "-t", targetName, "check-resource-type", "-r", "mypipeline/myresource", "--shallow", "-a")
|
||||
sess, err := gexec.Start(flyCmd, GinkgoWriter, GinkgoWriter)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
|
@ -126,7 +126,7 @@ var _ = Describe("CheckResourceType", func() {
|
|||
})
|
||||
})
|
||||
|
||||
Context("when watching the check succeed", func() {
|
||||
Context("when the check succeed", func() {
|
||||
BeforeEach(func() {
|
||||
expectedURL := "/api/v1/teams/main/pipelines/mypipeline/resource-types/myresource/check"
|
||||
atcServer.AppendHandlers(
|
||||
|
@ -150,7 +150,7 @@ var _ = Describe("CheckResourceType", func() {
|
|||
|
||||
It("sends check resource request to ATC", func() {
|
||||
Expect(func() {
|
||||
flyCmd = exec.Command(flyPath, "-t", targetName, "check-resource-type", "-r", "mypipeline/myresource", "-w")
|
||||
flyCmd = exec.Command(flyPath, "-t", targetName, "check-resource-type", "-r", "mypipeline/myresource", "--shallow")
|
||||
sess, err := gexec.Start(flyCmd, GinkgoWriter, GinkgoWriter)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
|
@ -173,7 +173,7 @@ var _ = Describe("CheckResourceType", func() {
|
|||
})
|
||||
})
|
||||
|
||||
Context("when watching the check fail", func() {
|
||||
Context("when the check fail", func() {
|
||||
BeforeEach(func() {
|
||||
expectedURL := "/api/v1/teams/main/pipelines/mypipeline/resource-types/myresource/check"
|
||||
atcServer.AppendHandlers(
|
||||
|
@ -198,7 +198,7 @@ var _ = Describe("CheckResourceType", func() {
|
|||
|
||||
It("sends check resource request to ATC", func() {
|
||||
Expect(func() {
|
||||
flyCmd = exec.Command(flyPath, "-t", targetName, "check-resource-type", "-r", "mypipeline/myresource", "-w")
|
||||
flyCmd = exec.Command(flyPath, "-t", targetName, "check-resource-type", "-r", "mypipeline/myresource", "--shallow")
|
||||
sess, err := gexec.Start(flyCmd, GinkgoWriter, GinkgoWriter)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
|
@ -266,7 +266,7 @@ var _ = Describe("CheckResourceType", func() {
|
|||
|
||||
It("sends check resource request to ATC", func() {
|
||||
Expect(func() {
|
||||
flyCmd = exec.Command(flyPath, "-t", targetName, "check-resource-type", "-r", "mypipeline/myresource", "--recursive")
|
||||
flyCmd = exec.Command(flyPath, "-t", targetName, "check-resource-type", "-r", "mypipeline/myresource", "-a")
|
||||
sess, err := gexec.Start(flyCmd, GinkgoWriter, GinkgoWriter)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
|
@ -341,7 +341,7 @@ var _ = Describe("CheckResourceType", func() {
|
|||
|
||||
It("sends check resource request to ATC", func() {
|
||||
Expect(func() {
|
||||
flyCmd = exec.Command(flyPath, "-t", targetName, "check-resource-type", "-r", "mypipeline/myresource", "--recursive")
|
||||
flyCmd = exec.Command(flyPath, "-t", targetName, "check-resource-type", "-r", "mypipeline/myresource", "-a")
|
||||
sess, err := gexec.Start(flyCmd, GinkgoWriter, GinkgoWriter)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
|
@ -377,7 +377,7 @@ var _ = Describe("CheckResourceType", func() {
|
|||
})
|
||||
|
||||
It("fails with error", func() {
|
||||
flyCmd = exec.Command(flyPath, "-t", targetName, "check-resource-type", "-r", "mypipeline/myresource")
|
||||
flyCmd = exec.Command(flyPath, "-t", targetName, "check-resource-type", "-r", "mypipeline/myresource", "--shallow")
|
||||
sess, err := gexec.Start(flyCmd, GinkgoWriter, GinkgoWriter)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
|
@ -399,7 +399,7 @@ var _ = Describe("CheckResourceType", func() {
|
|||
})
|
||||
|
||||
It("outputs error in response body", func() {
|
||||
flyCmd = exec.Command(flyPath, "-t", targetName, "check-resource-type", "-r", "mypipeline/myresource")
|
||||
flyCmd = exec.Command(flyPath, "-t", targetName, "check-resource-type", "-r", "mypipeline/myresource", "--shallow")
|
||||
sess, err := gexec.Start(flyCmd, GinkgoWriter, GinkgoWriter)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
|
|
|
@ -12,29 +12,15 @@ var _ = Describe("When a resource type depends on another resource type", func()
|
|||
setAndUnpausePipeline("fixtures/recursive-resource-checking.yml")
|
||||
})
|
||||
|
||||
It("errors when parent has no version", func() {
|
||||
check := spawnFly("check-resource", "-r", inPipeline("recursive-custom-resource"), "-w")
|
||||
It("can be checked shallowly and errors when parent has no version", func() {
|
||||
check := spawnFly("check-resource", "-r", inPipeline("recursive-custom-resource"), "--shallow")
|
||||
<-check.Exited
|
||||
Expect(check).To(gexec.Exit(1))
|
||||
Expect(check.Err).To(gbytes.Say("parent type has no version"))
|
||||
})
|
||||
|
||||
It("can be checked in order", func() {
|
||||
check := fly("check-resource-type", "-r", inPipeline("mock-resource-parent"), "-w")
|
||||
Expect(check).To(gbytes.Say("mock-resource-parent.*succeeded"))
|
||||
|
||||
check = fly("check-resource-type", "-r", inPipeline("mock-resource-child"), "-w")
|
||||
Expect(check).To(gbytes.Say("mock-resource-child.*succeeded"))
|
||||
|
||||
check = fly("check-resource-type", "-r", inPipeline("mock-resource-grandchild"), "-w")
|
||||
Expect(check).To(gbytes.Say("mock-resource-grandchild.*succeeded"))
|
||||
|
||||
check = fly("check-resource", "-r", inPipeline("recursive-custom-resource"), "-w")
|
||||
Expect(check).To(gbytes.Say("recursive-custom-resource.*succeeded"))
|
||||
})
|
||||
|
||||
It("can be checked recursively", func() {
|
||||
check := fly("check-resource", "-r", inPipeline("recursive-custom-resource"), "-w", "--recursive")
|
||||
check := fly("check-resource", "-r", inPipeline("recursive-custom-resource"))
|
||||
Expect(check).To(gbytes.Say("mock-resource-parent.*succeeded"))
|
||||
Expect(check).To(gbytes.Say("mock-resource-child.*succeeded"))
|
||||
Expect(check).To(gbytes.Say("mock-resource-grandchild.*succeeded"))
|
||||
|
|
|
@ -289,7 +289,7 @@ run:
|
|||
|
||||
It("runs the task without error", func() {
|
||||
By("having an initial version")
|
||||
fly("check-resource", "-r", pipelineName+"/some-resource", "-f", "version:first-version", "-w")
|
||||
fly("check-resource", "-r", pipelineName+"/some-resource", "-f", "version:first-version")
|
||||
|
||||
By("satisfying the job's passed constraint for the first version")
|
||||
fly("trigger-job", "-w", "-j", pipelineName+"/upstream-job")
|
||||
|
@ -302,7 +302,7 @@ run:
|
|||
Expect(execS).To(gbytes.Say("first-version"))
|
||||
|
||||
By("finding another version that doesn't yet satisfy the passed constraint")
|
||||
fly("check-resource", "-r", pipelineName+"/some-resource", "-f", "version:second-version", "-w")
|
||||
fly("check-resource", "-r", pipelineName+"/some-resource", "-f", "version:second-version")
|
||||
|
||||
By("still executing using the first version via -j")
|
||||
execS = flyIn(tmp, "execute", "-c", "task.yml", "-j", pipelineName+"/downstream-job")
|
||||
|
@ -352,7 +352,7 @@ run:
|
|||
|
||||
It("runs the task without error", func() {
|
||||
By("having an initial version")
|
||||
fly("check-resource", "-r", pipelineName+"/some-resource", "-f", "version:first-version", "-w")
|
||||
fly("check-resource", "-r", pipelineName+"/some-resource", "-f", "version:first-version")
|
||||
|
||||
By("satisfying the job's passed constraint for the first version")
|
||||
fly("trigger-job", "-w", "-j", pipelineName+"/upstream-job")
|
||||
|
@ -365,7 +365,7 @@ run:
|
|||
Expect(execS).To(gbytes.Say("first-version"))
|
||||
|
||||
By("finding another version that doesn't yet satisfy the passed constraint")
|
||||
fly("check-resource", "-r", pipelineName+"/some-resource", "-f", "version:second-version", "-w")
|
||||
fly("check-resource", "-r", pipelineName+"/some-resource", "-f", "version:second-version")
|
||||
|
||||
By("still executing using the first version via -j")
|
||||
execS = flyIn(tmp, "execute", "-c", "task.yml", "-j", pipelineName+"/downstream-job", "-m", "mapped-resource=some-resource")
|
||||
|
@ -411,7 +411,7 @@ run:
|
|||
|
||||
It("runs the task without error", func() {
|
||||
By("having an initial version")
|
||||
fly("check-resource", "-r", pipelineName+"/some-resource", "-f", "version:first-version", "-w")
|
||||
fly("check-resource", "-r", pipelineName+"/some-resource", "-f", "version:first-version")
|
||||
|
||||
By("satisfying the job's passed constraint for the first version")
|
||||
fly("trigger-job", "-w", "-j", pipelineName+"/upstream-job")
|
||||
|
@ -424,7 +424,7 @@ run:
|
|||
Expect(execS).To(gbytes.Say("first-version"))
|
||||
|
||||
By("finding another version that doesn't yet satisfy the passed constraint")
|
||||
fly("check-resource", "-r", pipelineName+"/some-resource", "-f", "version:second-version", "-w")
|
||||
fly("check-resource", "-r", pipelineName+"/some-resource", "-f", "version:second-version")
|
||||
|
||||
By("still executing using the first version via -j")
|
||||
execS = flyIn(tmp, "execute", "-c", "task.yml", "-j", pipelineName+"/downstream-job", "--image", "some-image")
|
||||
|
|
|
@ -22,7 +22,7 @@ var _ = Describe("A resource pinned with a version during initial set of the pip
|
|||
})
|
||||
|
||||
It("should be able to check the resource", func() {
|
||||
check := fly("check-resource", "-r", inPipeline("some-resource"), "-w")
|
||||
check := fly("check-resource", "-r", inPipeline("some-resource"))
|
||||
Expect(check).To(gbytes.Say("some-resource.*succeeded"))
|
||||
})
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ var _ = Describe("Checking a resource", func() {
|
|||
})
|
||||
|
||||
It("can check a resource recursively", func() {
|
||||
watch := fly("check-resource", "-r", inPipeline("some-git-resource"), "-w", "--recursive")
|
||||
watch := fly("check-resource", "-r", inPipeline("some-git-resource"))
|
||||
Expect(watch).To(gbytes.Say("some-git-resource.*succeeded"))
|
||||
})
|
||||
})
|
||||
|
|
|
@ -29,7 +29,7 @@ var _ = Describe("A resource check which times out", func() {
|
|||
})
|
||||
|
||||
It("prints an error and cancels the check", func() {
|
||||
check := spawnFly("check-resource", "-r", inPipeline("my-resource"), "-w")
|
||||
check := spawnFly("check-resource", "-r", inPipeline("my-resource"))
|
||||
<-check.Exited
|
||||
Expect(check).To(gexec.Exit(1))
|
||||
Expect(check.Out).To(gbytes.Say("errored"))
|
||||
|
@ -43,7 +43,7 @@ var _ = Describe("A resource check which times out", func() {
|
|||
})
|
||||
|
||||
It("succeeds", func() {
|
||||
fly("check-resource", "-r", inPipeline("my-resource"), "-w")
|
||||
fly("check-resource", "-r", inPipeline("my-resource"))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -31,7 +31,7 @@ var _ = Describe("Resource config versions", func() {
|
|||
|
||||
newVersion := u.String()
|
||||
|
||||
fly("check-resource-type", "-r", inPipeline("custom-resource-type"), "-f", "version:"+newVersion, "-w")
|
||||
fly("check-resource-type", "-r", inPipeline("custom-resource-type"), "-f", "version:"+newVersion)
|
||||
|
||||
By("triggering a job using the custom type")
|
||||
fly("trigger-job", "-j", inPipeline("passed-job"), "-w")
|
||||
|
|
|
@ -20,7 +20,7 @@ var _ = Describe("Resource-types checks", func() {
|
|||
})
|
||||
|
||||
It("can check the resource-type", func() {
|
||||
checkS := fly("check-resource-type", "-r", inPipeline("custom-resource-type"), "-w")
|
||||
checkS := fly("check-resource-type", "-r", inPipeline("custom-resource-type"))
|
||||
Eventually(checkS).Should(gbytes.Say("succeeded"))
|
||||
})
|
||||
|
||||
|
@ -33,7 +33,7 @@ var _ = Describe("Resource-types checks", func() {
|
|||
|
||||
newVersion = u.String()
|
||||
|
||||
fly("check-resource-type", "-r", inPipeline("custom-resource-type"), "-f", "version:"+newVersion, "-w")
|
||||
fly("check-resource-type", "-r", inPipeline("custom-resource-type"), "-f", "version:"+newVersion)
|
||||
})
|
||||
|
||||
It("uses the updated resource type", func() {
|
||||
|
@ -44,7 +44,7 @@ var _ = Describe("Resource-types checks", func() {
|
|||
|
||||
Context("when the resource-type check fails", func() {
|
||||
It("fails", func() {
|
||||
watch := spawnFly("check-resource-type", "-r", inPipeline("failing-custom-resource-type"), "-w")
|
||||
watch := spawnFly("check-resource-type", "-r", inPipeline("failing-custom-resource-type"))
|
||||
Eventually(watch.Out).Should(gbytes.Say("errored"))
|
||||
Eventually(watch).Should(gexec.Exit(1))
|
||||
})
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
"github.com/onsi/gomega/gbytes"
|
||||
"github.com/onsi/gomega/gexec"
|
||||
)
|
||||
|
||||
var _ = Describe("Configuring a resource type in a pipeline config", func() {
|
||||
|
@ -34,10 +35,17 @@ var _ = Describe("Configuring a resource type in a pipeline config", func() {
|
|||
})
|
||||
|
||||
It("can check for resources having a custom type recursively", func() {
|
||||
checkResource := fly("check-resource", "-r", inPipeline("my-resource"), "-w", "--recursive")
|
||||
checkResource := fly("check-resource", "-r", inPipeline("my-resource"))
|
||||
Expect(checkResource).To(gbytes.Say("custom-resource-type.*succeeded"))
|
||||
Expect(checkResource).To(gbytes.Say("my-resource.*succeeded"))
|
||||
})
|
||||
|
||||
It("can check for resources having a custom type shallowly and error out", func() {
|
||||
checkResource := spawnFly("check-resource", "-r", inPipeline("my-resource"), "--shallow")
|
||||
<-checkResource.Exited
|
||||
Expect(checkResource).To(gexec.Exit(1))
|
||||
Expect(checkResource.Err).To(gbytes.Say("parent type has no version"))
|
||||
})
|
||||
})
|
||||
|
||||
Context("with custom resource types that have params", func() {
|
||||
|
|
|
@ -272,7 +272,7 @@ func newMockVersion(resourceName string, tag string) string {
|
|||
|
||||
version := guid.String() + "-" + tag
|
||||
|
||||
fly("check-resource", "-r", inPipeline(resourceName), "-f", "version:"+version, "-w")
|
||||
fly("check-resource", "-r", inPipeline(resourceName), "-f", "version:"+version)
|
||||
|
||||
return version
|
||||
}
|
||||
|
|
|
@ -23,12 +23,12 @@ var _ = Describe("A job with an input with trigger: true", func() {
|
|||
|
||||
It("triggers when the resource changes", func() {
|
||||
By("running on the initial version")
|
||||
fly("check-resource", "-r", inPipeline("some-resource"), "-f", "version:first-version", "-w")
|
||||
fly("check-resource", "-r", inPipeline("some-resource"), "-f", "version:first-version")
|
||||
watch := waitForBuildAndWatch("some-passing-job")
|
||||
Eventually(watch).Should(gbytes.Say("first-version"))
|
||||
|
||||
By("running again when there's a new version")
|
||||
fly("check-resource", "-r", inPipeline("some-resource"), "-f", "version:second-version", "-w")
|
||||
fly("check-resource", "-r", inPipeline("some-resource"), "-f", "version:second-version")
|
||||
watch = waitForBuildAndWatch("some-passing-job", "2")
|
||||
Eventually(watch).Should(gbytes.Say("second-version"))
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue