コード例 #1
0
ファイル: routing_api_test.go プロジェクト: vframbach/cli
		requirement requirements.RoutingAPIRequirement
	)

	BeforeEach(func() {
		ui = new(testterm.FakeUI)
		config = testconfig.NewRepositoryWithAccessToken(core_config.TokenInfo{Username: "******"})
		requirement = requirements.NewRoutingAPIRequirement(ui, config)
	})

	Context("when the config has a zero-length RoutingApiEndpoint", func() {
		BeforeEach(func() {
			config.SetRoutingApiEndpoint("")
		})

		It("panics and prints a failure message", func() {
			Expect(func() { requirement.Execute() }).To(Panic())
			Expect(ui.Outputs).To(ContainElement("Routing API URI missing. Please log in again to set the URI automatically."))
		})
	})

	Context("when the config has a RoutingApiEndpoint", func() {
		BeforeEach(func() {
			config.SetRoutingApiEndpoint("api.example.com")
		})

		It("does not print anything", func() {
			requirement.Execute()
			Expect(ui.Outputs).To(BeEmpty())
		})

		It("returns true", func() {
コード例 #2
0
ファイル: routing_api_test.go プロジェクト: Reejoshi/cli
		config      coreconfig.Repository
		requirement requirements.RoutingAPIRequirement
	)

	BeforeEach(func() {
		config = testconfig.NewRepositoryWithAccessToken(coreconfig.TokenInfo{Username: "******"})
		requirement = requirements.NewRoutingAPIRequirement(config)
	})

	Context("when the config has a zero-length RoutingAPIEndpoint", func() {
		BeforeEach(func() {
			config.SetRoutingAPIEndpoint("")
		})

		It("errors", func() {
			err := requirement.Execute()
			Expect(err.Error()).To(ContainSubstring("This command requires the Routing API. Your targeted endpoint reports it is not enabled."))
		})
	})

	Context("when the config has a RoutingAPIEndpoint", func() {
		BeforeEach(func() {
			config.SetRoutingAPIEndpoint("api.example.com")
		})

		It("does not error", func() {
			err := requirement.Execute()
			Expect(err).NotTo(HaveOccurred())
		})
	})
})