"github.com/cloudfoundry/cli/cf/commandregistry"
	"github.com/cloudfoundry/cli/cf/terminal/terminalfakes"
	"github.com/cloudfoundry/cli/cf/trace/tracefakes"
	. "github.com/cloudfoundry/cli/plugin/rpc"
	. "github.com/cloudfoundry/cli/plugin/rpc/fakecommand"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("calling commands in commandregistry", func() {

	_ = FakeCommand1{} //make sure fake_command is imported and self-registered with init()

	var (
		ui         *terminalfakes.FakeUI
		deps       commandregistry.Dependency
		fakeLogger *tracefakes.FakePrinter
	)

	BeforeEach(func() {
		fakeLogger = new(tracefakes.FakePrinter)
		deps = commandregistry.NewDependency(os.Stdout, fakeLogger)
		ui = new(terminalfakes.FakeUI)
		deps.UI = ui

		cmd := commandregistry.Commands.FindCommand("fake-command")
		commandregistry.Commands.SetCommand(cmd.SetDependency(deps, true))

		cmd2 := commandregistry.Commands.FindCommand("fake-command2")
		commandregistry.Commands.SetCommand(cmd2.SetDependency(deps, true))
	})
Exemple #2
0
	"github.com/cloudfoundry/cli/cf/terminal/terminalfakes"
	"github.com/cloudfoundry/cli/flags"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/onsi/gomega/gbytes"
)

var _ = Describe("Help", func() {

	commandsloader.Load()

	var (
		fakeFactory *testreq.FakeReqFactory
		fakeUI      *terminalfakes.FakeUI
		fakeConfig  *pluginconfigfakes.FakePluginConfiguration
		deps        commandregistry.Dependency

		cmd         *commands.Help
		flagContext flags.FlagContext
		buffer      *gbytes.Buffer
	)

	BeforeEach(func() {
		buffer = gbytes.NewBuffer()
		fakeUI = new(terminalfakes.FakeUI)
		fakeUI.WriterReturns(buffer)

		fakeConfig = new(pluginconfigfakes.FakePluginConfiguration)

		deps = commandregistry.Dependency{
			UI:           fakeUI,
			PluginConfig: fakeConfig,
Exemple #3
0
	"github.com/cloudfoundry/cli/cf/errors/errorsfakes"

	"github.com/cloudfoundry/cli/cf/api/apifakes"
	cferrors "github.com/cloudfoundry/cli/cf/errors"
	"github.com/cloudfoundry/cli/cf/models"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"

	"github.com/cloudfoundry/cli/cf/terminal/terminalfakes"
)

var _ = Describe("Routes", func() {
	var (
		fakeUI              *terminalfakes.FakeUI
		fakeRouteRepository *apifakes.FakeRouteRepository
		routeActor          RouteActor

		expectedRoute  models.Route
		expectedDomain models.DomainFields
	)

	BeforeEach(func() {
		fakeUI = &terminalfakes.FakeUI{}
		fakeRouteRepository = new(apifakes.FakeRouteRepository)
		routeActor = NewRouteActor(fakeUI, fakeRouteRepository)
	})

	Describe("CreateRandomTCPRoute", func() {
		BeforeEach(func() {
			expectedDomain = models.DomainFields{
				Name: "dies-tcp.com",
			}
package net_test

import (
	"os"

	"github.com/cloudfoundry/cli/cf/net"
	"github.com/cloudfoundry/cli/cf/net/netfakes"
	"github.com/cloudfoundry/cli/cf/terminal/terminalfakes"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("WarningsCollector", func() {
	var (
		ui                 *terminalfakes.FakeUI
		oldRaiseErrorValue string
		warningsCollector  net.WarningsCollector
	)

	BeforeEach(func() {
		ui = new(terminalfakes.FakeUI)
	})

	Describe("PrintWarnings", func() {
		BeforeEach(func() {
			oldRaiseErrorValue = os.Getenv("CF_RAISE_ERROR_ON_WARNINGS")
		})

		AfterEach(func() {
			os.Setenv("CF_RAISE_ERROR_ON_WARNINGS", oldRaiseErrorValue)
		})
Exemple #5
0
package panicprinter_test

import (
	"github.com/cloudfoundry/cli/cf/errors"
	. "github.com/cloudfoundry/cli/cf/panicprinter"

	"github.com/cloudfoundry/cli/cf/terminal/terminalfakes"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Panic Printer", func() {
	var (
		ui           *terminalfakes.FakeUI
		panicPrinter PanicPrinter
	)

	BeforeEach(func() {
		ui = new(terminalfakes.FakeUI)
		panicPrinter = NewPanicPrinter(ui)
	})

	Describe("DisplayCrashDialog", func() {
		It("includes the error message when given an error", func() {
			panicPrinter.DisplayCrashDialog(errors.New("some-error"), "some command", "some trace")
			Expect(ui.SayCallCount()).To(Equal(1))
			Expect(ui.SayArgsForCall(0)).To(Equal(CrashDialog("some-error", "some command", "some trace")))
		})

		It("includes the string when given a string that is not terminal.QuietPanic", func() {
			panicPrinter.DisplayCrashDialog("some-error", "some command", "some trace")
Exemple #6
0
	"errors"

	. "github.com/cloudfoundry/cli/cf/actors"

	"github.com/cloudfoundry/cli/cf/api/apifakes"
	"github.com/cloudfoundry/cli/cf/models"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"

	"github.com/cloudfoundry/cli/cf/terminal/terminalfakes"
)

var _ = Describe("Routes", func() {
	var (
		fakeUI              *terminalfakes.FakeUI
		fakeRouteRepository *apifakes.FakeRouteRepository
		routeActor          RouteActor
	)

	BeforeEach(func() {
		fakeUI = &terminalfakes.FakeUI{}
		fakeRouteRepository = new(apifakes.FakeRouteRepository)
		routeActor = NewRouteActor(fakeUI, fakeRouteRepository)
	})

	Describe("creating a random TCP route", func() {
		var (
			domain models.DomainFields
			route  models.Route
		)