示例#1
0
				[]string{"Incorrect Usage", "Requires an argument"},
			))
			Expect(passed).To(BeFalse())
		})
	})

	Context("when logged in, a space is targeted and a valid app name is provided", func() {
		BeforeEach(func() {
			app := models.Application{}
			app.Name = "my-found-app"
			app.Guid = "my-app-guid"

			requirementsFactory.Application = app
			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"))
示例#2
0
文件: files_test.go 项目: QwaQ/cli
					[]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"}))
				})

				Context("when the files are empty", func() {
					BeforeEach(func() {
						appFilesRepo.ListFilesReturns("", nil)
					})

					It("tells the user no files were found", func() {
						cmd.Execute(flagContext)
						Expect(ui.Outputs).To(ContainSubstrings([]string{"No files found"}))