Example #1
0
import (
	"github.com/cloudfoundry/cli/cf/configuration/core_config"
	"github.com/cloudfoundry/cli/cf/requirements"

	testconfig "github.com/cloudfoundry/cli/testhelpers/configuration"
	testterm "github.com/cloudfoundry/cli/testhelpers/terminal"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("RoutingApi", func() {
	var (
		ui          *testterm.FakeUI
		config      core_config.Repository
		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() {
Example #2
0
package requirements_test

import (
	"github.com/cloudfoundry/cli/cf/configuration/coreconfig"
	"github.com/cloudfoundry/cli/cf/requirements"

	testconfig "github.com/cloudfoundry/cli/testhelpers/configuration"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("RoutingApi", func() {
	var (
		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."))