var (
		fakeTargetVerifier           *fake_target_verifier.FakeTargetVerifier
		fakeReceptorClientCreator    *fake_receptor_client_creator.FakeCreator
		fakeExitHandler              *fake_exit_handler.FakeExitHandler
		outputBuffer                 *gbytes.Buffer
		terminalUI                   terminal.UI
		cliApp                       *cli.App
		cliConfig                    *config.Config
		latticeVersion, diegoVersion string
	)

	BeforeEach(func() {
		fakeTargetVerifier = &fake_target_verifier.FakeTargetVerifier{}
		fakeReceptorClientCreator = &fake_receptor_client_creator.FakeCreator{}
		fakeExitHandler = &fake_exit_handler.FakeExitHandler{}
		memPersister := persister.NewMemPersister()
		outputBuffer = gbytes.NewBuffer()
		terminalUI = terminal.NewUI(nil, outputBuffer, nil)
		cliConfig = config.New(memPersister)
		latticeVersion, diegoVersion = "v0.2.Test", "0.12345.0"

		fakeReceptorClientCreator.CreateReceptorClientReturns(&fake_receptor.FakeClient{})
	})

	JustBeforeEach(func() {
		cliApp = cli_app_factory.MakeCliApp(
			diegoVersion,
			latticeVersion,
			"~/",
			fakeExitHandler,
			cliConfig,
Beispiel #2
0
var _ = Describe("DropletRunner", func() {
	var (
		fakeAppRunner       *fake_app_runner.FakeAppRunner
		fakeTaskRunner      *fake_task_runner.FakeTaskRunner
		config              *config_package.Config
		fakeBlobStore       *fake_blob_store.FakeBlobStore
		fakeAppExaminer     *fake_app_examiner.FakeAppExaminer
		fakeProxyConfReader *fake_proxyconf_reader.FakeProxyConfReader
		dropletRunner       droplet_runner.DropletRunner
	)

	BeforeEach(func() {
		fakeAppRunner = &fake_app_runner.FakeAppRunner{}
		fakeTaskRunner = &fake_task_runner.FakeTaskRunner{}
		config = config_package.New(persister.NewMemPersister())
		fakeBlobStore = &fake_blob_store.FakeBlobStore{}
		fakeAppExaminer = &fake_app_examiner.FakeAppExaminer{}
		fakeProxyConfReader = &fake_proxyconf_reader.FakeProxyConfReader{}
		dropletRunner = droplet_runner.New(fakeAppRunner, fakeTaskRunner, config, fakeBlobStore, fakeAppExaminer, fakeProxyConfReader)
	})

	Describe("ListDroplets", func() {
		It("returns a list of droplets in the blob store", func() {
			fakeBlobStore.ListReturns([]blob.Blob{
				{Path: "X/bits.zip", Created: time.Unix(1000, 0), Size: 100},
				{Path: "X/droplet.tgz", Created: time.Unix(2000, 0), Size: 200},
				{Path: "X/result.json", Created: time.Unix(3000, 0), Size: 300},
				{Path: "Y/bits.zip"},
				{Path: "X/Y/droplet.tgz"},
				{Path: "droplet.tgz"},
	subCommandTemplate := `NAME:
   {{.Name}} - {{.Usage}}
USAGE:
   {{.Name}} command{{if .Flags}} [command options]{{end}} [arguments...]
`
	BeforeEach(func() {
		outputBuffer = gbytes.NewBuffer()

		fakeReceptorClientCreator = &fake_receptor_client_creator.FakeCreator{}

		cliApp = cli_app_factory.MakeCliApp(
			"",
			"",
			"~/",
			nil,
			config.New(persister.NewMemPersister()),
			nil,
			fakeReceptorClientCreator,
			nil,
			terminal.NewUI(nil, outputBuffer, nil),
		)
	})

	Describe("ShowHelp", func() {

		It("shows help for all commands", func() {
			Expect(cliApp.Commands).NotTo(BeEmpty())

			cli_app_factory.ShowHelp(outputBuffer, dummyTemplate, cliApp)

			outputBytes, err := ioutil.ReadAll(outputBuffer)
		fakeBlobStoreVerifier *fake_blob_store_verifier.FakeBlobStoreVerifier
		fakeExitHandler       *fake_exit_handler.FakeExitHandler
		fakePasswordReader    *mocks.FakePasswordReader
		fakeVersionManager    *fake_version_manager.FakeVersionManager
	)

	BeforeEach(func() {
		stdinReader, stdinWriter = io.Pipe()
		outputBuffer = gbytes.NewBuffer()
		fakeExitHandler = &fake_exit_handler.FakeExitHandler{}
		fakePasswordReader = &mocks.FakePasswordReader{}
		terminalUI = terminal.NewUI(stdinReader, outputBuffer, fakePasswordReader)
		fakeTargetVerifier = &fake_target_verifier.FakeTargetVerifier{}
		fakeBlobStoreVerifier = &fake_blob_store_verifier.FakeBlobStoreVerifier{}
		fakeVersionManager = &fake_version_manager.FakeVersionManager{}
		configPersister = persister.NewMemPersister()
		config = config_package.New(configPersister)
	})

	Describe("TargetCommand", func() {
		var targetCommand cli.Command

		verifyOldTargetStillSet := func() {
			newConfig := config_package.New(configPersister)
			Expect(newConfig.Load()).To(Succeed())

			Expect(newConfig.Receptor()).To(Equal("http://*****:*****@receptor.oldtarget.com"))
		}

		BeforeEach(func() {
			commandFactory := command_factory.NewConfigCommandFactory(config, terminalUI, fakeTargetVerifier, fakeBlobStoreVerifier, fakeExitHandler, fakeVersionManager)