From c043d4ac0255c25fb453d00a38fb351b7b1f9b53 Mon Sep 17 00:00:00 2001 From: JT Archie Date: Wed, 31 Oct 2018 14:28:50 -0600 Subject: [PATCH] fix download file output change from defer to direct function call --- commands/download_product.go | 6 ++---- commands/download_product_test.go | 3 +++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/commands/download_product.go b/commands/download_product.go index aa3c65564..94e39f9ea 100644 --- a/commands/download_product.go +++ b/commands/download_product.go @@ -85,8 +85,6 @@ func (c DownloadProduct) Execute(args []string) error { var productFileName, stemcellFileName string var releaseID int - defer c.writerDownloadedFileList(productFileName, stemcellFileName) - c.init() releaseID, productFileName, err = c.downloadProductFile(c.Options.ProductSlug, c.Options.ProductVersion, c.Options.FileGlob) @@ -95,7 +93,7 @@ func (c DownloadProduct) Execute(args []string) error { } if !c.Options.Stemcell { - return nil + return c.writerDownloadedFileList(productFileName, stemcellFileName) } c.logger.Info("Downloading stemcell") @@ -121,7 +119,7 @@ func (c DownloadProduct) Execute(args []string) error { return fmt.Errorf("could not download stemcell: %s", err) } - return nil + return c.writerDownloadedFileList(productFileName, stemcellFileName) } func (c DownloadProduct) writerDownloadedFileList(productFileName string, stemcellFileName string) error { diff --git a/commands/download_product_test.go b/commands/download_product_test.go index f4f42ce58..02f8fe3f6 100644 --- a/commands/download_product_test.go +++ b/commands/download_product_test.go @@ -95,7 +95,10 @@ var _ = Describe("DownloadProduct", func() { Expect(productFileID).To(Equal(54321)) fileName := path.Join(tempDir, commands.DownloadListFilename) + fileContent, err := ioutil.ReadFile(fileName) + Expect(err).NotTo(HaveOccurred()) Expect(fileName).To(BeAnExistingFile()) + Expect(string(fileContent)).To(MatchJSON(fmt.Sprintf(`{"product": "%s" }`, file.Name()))) }) Context("when the globs returns multiple files", func() {