예제 #1
0
	"code.cloudfoundry.org/cli/cf/terminal/terminalfakes"
	"code.cloudfoundry.org/cli/cf/trace/tracefakes"
	. "code.cloudfoundry.org/cli/plugin/rpc"
	. "code.cloudfoundry.org/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()
	_ = FakeCommand3{} //make sure fake_command is imported and self-registered with init()
	_ = FakeCommand4{} //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))
	})
예제 #2
0
파일: help_test.go 프로젝트: fujitsu-cf/cli
	"code.cloudfoundry.org/cli/cf/flags"
	"code.cloudfoundry.org/cli/cf/terminal/terminalfakes"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/onsi/gomega/gbytes"
)

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

	commandsloader.Load()

	var (
		fakeFactory *requirementsfakes.FakeFactory
		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,
예제 #3
0
package net_test

import (
	"os"

	"code.cloudfoundry.org/cli/cf/net"
	"code.cloudfoundry.org/cli/cf/net/netfakes"
	"code.cloudfoundry.org/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)
		})
예제 #4
0
import (
	"os"
	"time"

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

var _ = Describe("ProgressReader", func() {
	var (
		testFile       *os.File
		err            error
		progressReader *ProgressReader
		ui             *terminalfakes.FakeUI
		b              []byte
		fileStat       os.FileInfo
	)

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

		testFile, err = os.Open("../../fixtures/test.file")
		Expect(err).NotTo(HaveOccurred())

		fileStat, err = testFile.Stat()
		Expect(err).NotTo(HaveOccurred())

		b = make([]byte, 1024)
		progressReader = NewProgressReader(testFile, ui, 1*time.Millisecond)
예제 #5
0
	"code.cloudfoundry.org/cli/cf/api/apifakes"
	cferrors "code.cloudfoundry.org/cli/cf/errors"
	"code.cloudfoundry.org/cli/cf/errors/errorsfakes"
	"code.cloudfoundry.org/cli/cf/models"
	"code.cloudfoundry.org/cli/cf/terminal/terminalfakes"
	"code.cloudfoundry.org/cli/utils/words/generator/generatorfakes"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

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

		expectedRoute  models.Route
		expectedDomain models.DomainFields
		wordGenerator  *generatorfakes.FakeWordGenerator
	)

	BeforeEach(func() {
		fakeUI = &terminalfakes.FakeUI{}
		fakeRouteRepository = new(apifakes.FakeRouteRepository)
		fakeDomainRepository = new(apifakes.FakeDomainRepository)
		routeActor = NewRouteActor(fakeUI, fakeRouteRepository, fakeDomainRepository)
		wordGenerator = new(generatorfakes.FakeWordGenerator)
	})

	Describe("CreateRandomTCPRoute", func() {
		BeforeEach(func() {
예제 #6
0
package panicprinter_test

import (
	"code.cloudfoundry.org/cli/cf/errors"
	. "code.cloudfoundry.org/cli/cf/panicprinter"

	"code.cloudfoundry.org/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")