コード例 #1
0
				Entry("it does not return an error", true, false, nil),
				Entry("it does not return an error", true, true, nil),
			)

			Context("when the organization is targeted", func() {
				BeforeEach(func() {
					fakeConfig.TargetedOrganizationReturns(configv3.Organization{
						GUID: "some-org-guid",
					})
				})

				DescribeTable("targeting space check",
					func(isSpaceTargeted bool, checkForTargeted bool, expectedError error) {
						if isSpaceTargeted {
							fakeConfig.TargetedSpaceReturns(configv3.Space{
								GUID: "some-space-guid",
							})
						}

						err := CheckTarget(fakeConfig, true, checkForTargeted)

						if expectedError != nil {
							Expect(err).To(MatchError(expectedError))
						} else {
							Expect(err).ToNot(HaveOccurred())
						}
					},

					Entry("it returns an error", false, true, NoTargetedSpaceError{BinaryName: "faceman"}),
					Entry("it does not return an error", false, false, nil),
					Entry("it does not return an error", true, false, nil),
コード例 #2
0
ファイル: api_command_test.go プロジェクト: sebrandon1/cli
			It("displays a tip", func() {
				Expect(err).ToNot(HaveOccurred())

				Expect(fakeUI.Out).To(Say("No api endpoint set. Use 'cf api' to set an endpoint"))
			})
		})

		Context("when the API is set", func() {
			BeforeEach(func() {
				fakeConfig.TargetReturns("some-api-target")
				fakeConfig.APIVersionReturns("some-version")
				fakeConfig.TargetedOrganizationReturns(configv3.Organization{
					Name: "some-org",
				})
				fakeConfig.TargetedSpaceReturns(configv3.Space{
					Name: "some-space",
				})
				fakeConfig.CurrentUserReturns(configv3.User{
					Name: "admin",
				}, nil)
			})

			It("outputs the standard target information", func() {
				Expect(err).ToNot(HaveOccurred())
				Expect(fakeUI.Out).To(Say("API endpoint:\\s+some-api-target"))
				Expect(fakeUI.Out).To(Say("API version:\\s+some-version"))
				Expect(fakeUI.Out).To(Say("User:\\s+admin"))
				Expect(fakeUI.Out).To(Say("Org:\\s+some-org"))
				Expect(fakeUI.Out).To(Say("Space:\\s+some-space"))
			})
		})