requirementsFactory.LoginSuccess = true requirementsFactory.TargetedSpaceSuccess = true appFilesRepo.ListFilesReturns("file 1\nfile 2", nil) }) It("it lists files in a directory", func() { runCommand("my-app", "/foo") Expect(ui.Outputs).To(ContainSubstrings( []string{"Getting files for app", "my-found-app", "my-org", "my-space", "my-user"}, []string{"OK"}, []string{"file 1"}, []string{"file 2"}, )) guid, _, path := appFilesRepo.ListFilesArgsForCall(0) Expect(guid).To(Equal("my-app-guid")) Expect(path).To(Equal("/foo")) }) It("does not interpolate or interpret special format characters as though it should be a format string", func() { appFilesRepo.ListFilesReturns("%s %d %i", nil) runCommand("my-app", "/foo") Expect(ui.Outputs).To(ContainSubstrings([]string{"%s %d %i"})) }) Context("checking for bad flags", func() { It("fails when non-positive value is given for instance", func() { runCommand("-i", "-1", "my-app")
Context("when given a valid instance", func() { BeforeEach(func() { args = []string{"app-name", "-i", "0"} }) It("tells the user it is getting the files", func() { cmd.Execute(flagContext) Expect(ui.Outputs).To(ContainSubstrings( []string{"Getting files for app app-name"}, )) }) It("tries to list the files", func() { cmd.Execute(flagContext) Expect(appFilesRepo.ListFilesCallCount()).To(Equal(1)) appGUID, instance, path := appFilesRepo.ListFilesArgsForCall(0) Expect(appGUID).To(Equal("app-guid")) Expect(instance).To(Equal(0)) Expect(path).To(Equal("/")) }) Context("when listing the files succeeds", func() { BeforeEach(func() { appFilesRepo.ListFilesReturns("files", nil) }) It("tells the user OK", func() { cmd.Execute(flagContext) Expect(ui.Outputs).To(ContainSubstrings([]string{"OK"})) })