From 69f70afc8b0670b29eb3a63fd921d5013b664e93 Mon Sep 17 00:00:00 2001 From: Rui Yang Date: Wed, 14 Aug 2019 22:34:56 +0800 Subject: [PATCH] fly,testflight: add --async and --shallow for check resource/type Signed-off-by: Rui Yang --- fly/commands/check_resource.go | 14 ++++++------- fly/commands/check_resource_type.go | 10 ++++------ fly/integration/check_resource_test.go | 22 ++++++++++----------- fly/integration/check_resource_type_test.go | 20 +++++++++---------- testflight/custom_resource_check_test.go | 20 +++---------------- testflight/flying_test.go | 12 +++++------ testflight/pinned_version_check_test.go | 2 +- testflight/resource_check_test.go | 2 +- testflight/resource_check_timeout_test.go | 4 ++-- testflight/resource_config_versions_test.go | 2 +- testflight/resource_type_check_test.go | 6 +++--- testflight/resource_type_test.go | 10 +++++++++- testflight/suite_test.go | 2 +- testflight/trigger_test.go | 4 ++-- 14 files changed, 60 insertions(+), 70 deletions(-) diff --git a/fly/commands/check_resource.go b/fly/commands/check_resource.go index e8e1c63ff..90f5d9904 100644 --- a/fly/commands/check_resource.go +++ b/fly/commands/check_resource.go @@ -14,10 +14,10 @@ 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"` + 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"` + 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) diff --git a/fly/commands/check_resource_type.go b/fly/commands/check_resource_type.go index 4893244b8..3232c42e3 100644 --- a/fly/commands/check_resource_type.go +++ b/fly/commands/check_resource_type.go @@ -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) diff --git a/fly/integration/check_resource_test.go b/fly/integration/check_resource_test.go index 86f486aca..ba7e0d925 100644 --- a/fly/integration/check_resource_test.go +++ b/fly/integration/check_resource_test.go @@ -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()) diff --git a/fly/integration/check_resource_type_test.go b/fly/integration/check_resource_type_test.go index 213879f75..0928188bb 100644 --- a/fly/integration/check_resource_type_test.go +++ b/fly/integration/check_resource_type_test.go @@ -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()) diff --git a/testflight/custom_resource_check_test.go b/testflight/custom_resource_check_test.go index 83997f2f9..4bd371ae8 100644 --- a/testflight/custom_resource_check_test.go +++ b/testflight/custom_resource_check_test.go @@ -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")) diff --git a/testflight/flying_test.go b/testflight/flying_test.go index 4e690ce7e..68964d143 100644 --- a/testflight/flying_test.go +++ b/testflight/flying_test.go @@ -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") diff --git a/testflight/pinned_version_check_test.go b/testflight/pinned_version_check_test.go index b4ffee1ea..bfbd4400c 100644 --- a/testflight/pinned_version_check_test.go +++ b/testflight/pinned_version_check_test.go @@ -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")) }) diff --git a/testflight/resource_check_test.go b/testflight/resource_check_test.go index 78756e54d..4f23278d9 100644 --- a/testflight/resource_check_test.go +++ b/testflight/resource_check_test.go @@ -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")) }) }) diff --git a/testflight/resource_check_timeout_test.go b/testflight/resource_check_timeout_test.go index 12b667afb..044774f33 100644 --- a/testflight/resource_check_timeout_test.go +++ b/testflight/resource_check_timeout_test.go @@ -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")) }) }) }) diff --git a/testflight/resource_config_versions_test.go b/testflight/resource_config_versions_test.go index 614b81895..55f1643b9 100644 --- a/testflight/resource_config_versions_test.go +++ b/testflight/resource_config_versions_test.go @@ -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") diff --git a/testflight/resource_type_check_test.go b/testflight/resource_type_check_test.go index b496d1b18..bf5365672 100644 --- a/testflight/resource_type_check_test.go +++ b/testflight/resource_type_check_test.go @@ -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)) }) diff --git a/testflight/resource_type_test.go b/testflight/resource_type_test.go index 05d587451..0ad473ce7 100644 --- a/testflight/resource_type_test.go +++ b/testflight/resource_type_test.go @@ -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() { diff --git a/testflight/suite_test.go b/testflight/suite_test.go index a5d386eb6..f03dcfa48 100644 --- a/testflight/suite_test.go +++ b/testflight/suite_test.go @@ -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 } diff --git a/testflight/trigger_test.go b/testflight/trigger_test.go index 1fa0ce78b..8ecc4be78 100644 --- a/testflight/trigger_test.go +++ b/testflight/trigger_test.go @@ -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")) })