func TestGetApps(t *testing.T) {
	conn := new(fakes.FakeCliConnection)

	content, fileReadErr := readFile("test-data/apps.json")

	if fileReadErr != nil {
		panic("Failed to read file: " + fileReadErr.Error())
	}

	conn.CliCommandWithoutTerminalOutputReturns(content, nil)

	cmd := new(DiegoMigrationCmd)

	space := Space{AppsUrl: "/fake-apps-url"}

	apps, err := cmd.getApps(conn, space)

	if err != nil {
		t.Errorf("getApps Returned an error: %v", err.Error())
	}

	if len(apps.Resources) == 0 {
		t.Error("expected at least one result from getApps")
	}

	for _, appResource := range apps.Resources {
		if appResource.Entity.Name == "" {
			t.Error("Name was null on SpaceResource.Entity")
		}
	}
}
func TestGetOrgs(t *testing.T) {
	conn := new(fakes.FakeCliConnection)

	content, fileReadErr := readFile("test-data/orgs.json")

	if fileReadErr != nil {
		panic("Failed to read file: " + fileReadErr.Error())
	}

	conn.CliCommandWithoutTerminalOutputReturns(content, nil)

	cmd := new(DiegoMigrationCmd)

	orgs, err := cmd.getOrgs(conn)

	if err != nil {
		t.Errorf("getOrgs Returned an error: %v", err.Error())
	}

	if len(orgs.Resources) == 0 {
		t.Error("expected at least one result from getOrgs")
	}

	for _, orgResource := range orgs.Resources {
		if orgResource.Entity.SpacesUrl == "" {
			t.Error("SpacesURL was null on OrgResource.Entity")
		}

		if orgResource.Entity.Name == "" {
			t.Error("Name was null on OrgResource.Entity")
		}
	}
}
func getAllCfCommands(connection *fakes.FakeCliConnection) (commands []string) {
	commands = []string{}
	for i := 0; i < connection.CliCommandCallCount(); i++ {
		args := connection.CliCommandArgsForCall(i)
		commands = append(commands, strings.Join(args, " "))
	}
	return
}
Example #4
0
import (
	"errors"

	"github.com/cloudfoundry-incubator/diego-ssh/cf-plugin/models"
	"github.com/cloudfoundry-incubator/diego-ssh/cf-plugin/models/app"
	"github.com/cloudfoundry/cli/plugin"
	"github.com/cloudfoundry/cli/plugin/fakes"

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

var _ = Describe("App", func() {
	var (
		fakeCliConnection *fakes.FakeCliConnection
		curler            models.Curler
		af                app.AppFactory
	)

	BeforeEach(func() {
		fakeCliConnection = &fakes.FakeCliConnection{}
	})

	JustBeforeEach(func() {
		af = app.NewAppFactory(fakeCliConnection, curler)
	})

	Describe("Get", func() {
		Context("when CC returns a valid app guid", func() {
			BeforeEach(func() {
				fakeCliConnection.CliCommandWithoutTerminalOutputStub = func(args ...string) ([]string, error) {
package diego_support_test

import (
	"errors"

	"github.com/cloudfoundry/cli/plugin/fakes"

	"github.com/cloudfoundry-incubator/diego-enabler/diego_support"

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

var _ = Describe("DiegoSupport", func() {
	var (
		fakeCliConnection *fakes.FakeCliConnection
		diegoSupport      *diego_support.DiegoSupport
	)

	BeforeEach(func() {
		fakeCliConnection = &fakes.FakeCliConnection{}
		fakeCliConnection.CliCommandWithoutTerminalOutputReturns([]string{""}, nil)
		diegoSupport = diego_support.NewDiegoSupport(fakeCliConnection)
	})

	Describe("SetDiegoFlag", func() {
		It("invokes CliCommandWithoutTerminalOutput()", func() {
			diegoSupport.SetDiegoFlag("123", false)

			Ω(fakeCliConnection.CliCommandWithoutTerminalOutputCallCount()).To(Equal(1))
		})
Example #6
0
package main

import (
	"github.com/cloudfoundry/cli/plugin/fakes"
	ioStub "github.com/cloudfoundry/cli/testhelpers/io"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("appenv", func() {
	var fakeCliConnection *fakes.FakeCliConnection
	var appenv *AppEnv

	BeforeEach(func() {
		fakeCliConnection = &fakes.FakeCliConnection{}
		fakeCliConnection.IsLoggedInStub = func() (bool, error) { return true, nil }

		appenv = &AppEnv{}
	})

	Context("when uninstalled", func() {
		It("does nothing", func() {
			output := ioStub.CaptureOutput(func() {
				appenv.Run(fakeCliConnection, []string{"CLI-MESSAGE-UNINSTALL"})
			})

			Expect(output).To(ConsistOf([]string{""}))
		})
	})

	Context("when not logged in", func() {
Example #7
0
package info_test

import (
	"errors"

	"github.com/cloudfoundry-incubator/diego-ssh/cf-plugin/models/info"
	"github.com/cloudfoundry/cli/plugin/fakes"

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

var _ = Describe("Info", func() {
	var (
		fakeCliConnection *fakes.FakeCliConnection
		infoFactory       info.InfoFactory
	)

	BeforeEach(func() {
		fakeCliConnection = &fakes.FakeCliConnection{}
		infoFactory = info.NewInfoFactory(fakeCliConnection)
	})

	Describe("Get", func() {
		var expectedJson string

		JustBeforeEach(func() {
			fakeCliConnection.CliCommandWithoutTerminalOutputReturns([]string{expectedJson}, nil)
		})

		Context("when retrieving /v2/info is successful", func() {
)

func slurp(filename string) []string {
	var b []string
	file, _ := os.Open(filename)
	defer file.Close()
	scanner := bufio.NewScanner(file)
	for scanner.Scan() {
		b = append(b, scanner.Text())
	}
	return b
}

var _ = Describe("UsageReport", func() {
	var api *APIHelper
	var fakeCliConnection *fakes.FakeCliConnection

	BeforeEach(func() {
		fakeCliConnection = &fakes.FakeCliConnection{}
		api = &APIHelper{}
	})

	Describe("Get orgs", func() {
		var orgsJSON []string

		BeforeEach(func() {
			orgsJSON = slurp("test-data/orgs.json")
		})

		It("should return two orgs", func() {
			fakeCliConnection.CliCommandWithoutTerminalOutputReturns(orgsJSON, nil)
	testterm "github.com/cloudfoundry/cli/testhelpers/terminal"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	// "os"
)

func fakeError(err error) {
	if err != nil {
		fmt.Println(err)
	}
}

var _ = Describe("WildcardPlugin", func() {
	var (
		ui                *testterm.FakeUI
		wildcardPlugin    *Wildcard
		fakeCliConnection *fakes.FakeCliConnection
		appsList          []plugin_models.GetAppsModel
	)
	Context("When running wildcard-apps", func() {
		BeforeEach(func() {
			appsList = make([]plugin_models.GetAppsModel, 0)
			appsList = append(appsList,
				plugin_models.GetAppsModel{"spring-music", "", "", 0, 0, 0, 0, nil},
				plugin_models.GetAppsModel{"app321", "", "", 0, 0, 0, 0, nil},
			)
			fakeCliConnection = &fakes.FakeCliConnection{}
			wildcardPlugin = &Wildcard{}
		})
		Describe("When there are matching apps", func() {
			It("prints a table containing only those apps", func() {
				fakeCliConnection.GetAppsReturns(appsList, nil)
package main

import (
	"time"

	"github.com/cloudfoundry/cli/plugin/fakes"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Scaleover", func() {
	var scaleoverCmdPlugin *ScaleoverCmd
	var fakeCliConnection *fakes.FakeCliConnection

	Describe("getAppStatus", func() {

		BeforeEach(func() {
			fakeCliConnection = &fakes.FakeCliConnection{}
			scaleoverCmdPlugin = &ScaleoverCmd{}
		})

		It("should Fail Without App 1", func() {
			fakeCliConnection.CliCommandWithoutTerminalOutputReturns([]string{"FAILED", "App app1 not found"}, nil)
			var err error
			_, err = scaleoverCmdPlugin.getAppStatus(fakeCliConnection, "app1")
			Expect(err.Error()).To(Equal("App app1 not found"))
		})

		It("should Fail Without App 2", func() {
			fakeCliConnection.CliCommandWithoutTerminalOutputReturns([]string{"FAILED", "App app2 not found"}, nil)
			var err error
            "updated_at": "2015-07-09T17:00:44Z"
         },
         "entity": {
            "name": "staticfile-buildpack",
            "position": 10,
            "enabled": true,
            "locked": false,
            "filename": "staticfile_buildpack-cached-v1.2.0.zip"
         }
      }
   ]
}`

var _ = Describe("BuildpackRepo", func() {
	Describe("ListAll", func() {
		var cliConnection *fakes.FakeCliConnection

		BeforeEach(func() {
			cliConnection = &fakes.FakeCliConnection{}
		})

		It("outputs a slice of all admin buildpacks", func() {
			cliConnection.CliCommandWithoutTerminalOutputReturns([]string{getBuildpacksJson}, nil)

			repo := NewCliBuildpackRepository(cliConnection)
			buildpacks, _ := repo.ListBuildpacks()

			Expect(buildpacks[0].Name).To(Equal("java"))
			Expect(buildpacks[0].Position).To(Equal(1))
			Expect(buildpacks[0].Enabled).To(Equal(true))
			Expect(buildpacks[0].Locked).To(Equal(false))
import (
	"errors"
	"net/http"
	"os"

	cliFakes "github.com/cloudfoundry/cli/plugin/fakes"
	. "github.com/krujos/download_droplet_plugin/droplet"
	"github.com/krujos/download_droplet_plugin/droplet/fakes"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/onsi/gomega/ghttp"
)

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

	var fakeCliConnection *cliFakes.FakeCliConnection
	var downloader *CFDownloader
	var server *ghttp.Server
	tarFileContents := "This is a tar file"

	BeforeEach(func() {
		fakeCliConnection = &cliFakes.FakeCliConnection{}
		downloader = &CFDownloader{Cli: fakeCliConnection}
		server = ghttp.NewServer()
		fakeCliConnection.AccessTokenReturns("bearer 1234", nil)
		fakeCliConnection.ApiEndpointReturns(server.URL(), nil)
		fakeCliConnection.IsSSLDisabledReturns(true, nil)
		server.AppendHandlers(
			ghttp.VerifyRequest("GET", "/v2/apps/1234/droplet/download"),
			ghttp.VerifyHeader(
				http.Header{
Example #13
0
package credential_test

import (
	"errors"

	"github.com/cloudfoundry-incubator/diego-ssh/cf-plugin/models/credential"
	"github.com/cloudfoundry/cli/plugin/fakes"

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

var _ = Describe("Credential", func() {
	var (
		fakeCliConnection *fakes.FakeCliConnection
		credFactory       credential.CredentialFactory
	)

	BeforeEach(func() {
		fakeCliConnection = &fakes.FakeCliConnection{}
		credFactory = credential.NewCredentialFactory(fakeCliConnection)
	})

	Describe("Get", func() {
		var expectedResponse []string

		Context("when retrieving /v2/info is successful", func() {
			BeforeEach(func() {
				expectedResponse = []string{
					"Getting OAuth token\n",
					"OK\n",
type FakeLogger struct {
	PrintSpy []string
}

func (s *FakeLogger) Fatalln(...interface{}) {
}

func (s *FakeLogger) Println(p ...interface{}) {
	fmt.Println(p)
	s.PrintSpy = append(s.PrintSpy, fmt.Sprint(p))
}

var _ = Describe("DeployCloudPlugin", func() {
	var (
		cliConn = new(cffakes.FakeCliConnection)
	)

	Describe("given .Run()", func() {
		Context("when called without valid arguments", func() {
			var (
				myLogger = new(FakeLogger)
				dcp      *DeployCloudPlugin
			)
			BeforeEach(func() {
				Logger = myLogger
				dcp = new(DeployCloudPlugin)
				dcp.Run(cliConn, []string{
					"cloud-deploy",
				})
			})
Example #15
0
			},
		)
		Ω(appName).Should(Equal("appname"))
		Ω(args).Should(Equal([]string{
			"push",
			"appname",
			"-f", "manifest-path",
			"-p", "app-path",
		}))
	})
})

var _ = Describe("Command Syntax", func() {

	var (
		cliConn         *fakes.FakeCliConnection
		autopilotPlugin *AutopilotPlugin
	)

	BeforeEach(func() {
		cliConn = &fakes.FakeCliConnection{}
		autopilotPlugin = &AutopilotPlugin{}
	})

	It("displays push usage when push-zdd called with no arguments", func() {
		autopilotPlugin.Run(cliConn, []string{"push-zdd"})

		Ω(cliConn.CliCommandCallCount()).Should(Equal(1))
		args := cliConn.CliCommandArgsForCall(0)
		Ω(args).Should(Equal([]string{"push", "-h"}))
	})
Example #16
0
package main_test

import (
	"github.com/cloudfoundry/cli/plugin/fakes"
	. "github.com/cloudfoundry/cli/plugin_examples/call_cli_cmd/main"
	io_helpers "github.com/cloudfoundry/cli/testhelpers/io"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("CallCliCmd", func() {
	Describe(".Run", func() {
		var fakeCliConnection *fakes.FakeCliConnection
		var callCliCommandPlugin *CliCmd

		BeforeEach(func() {
			fakeCliConnection = &fakes.FakeCliConnection{}
			callCliCommandPlugin = &CliCmd{}
		})

		It("calls the cli command that is passed as an argument", func() {
			io_helpers.CaptureOutput(func() {
				callCliCommandPlugin.Run(fakeCliConnection, []string{"cli-command", "plugins", "arg1"})
			})

			Expect(fakeCliConnection.CliCommandArgsForCall(0)[0]).To(Equal("plugins"))
			Expect(fakeCliConnection.CliCommandArgsForCall(0)[1]).To(Equal("arg1"))
		})

		It("ouputs the text returned by the cli command", func() {
			fakeCliConnection.CliCommandReturns([]string{"Hi", "Mom"}, nil)
Example #17
0
package main_test

import (
	. "."
	"github.com/cloudfoundry/cli/plugin/fakes"
	io_helpers "github.com/cloudfoundry/cli/testhelpers/io"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Cloud Foundry Copyenv Command", func() {
	Describe(".Run", func() {
		var fakeCliConnection *fakes.FakeCliConnection
		var callCopyEnvCommandPlugin *CopyEnv

		BeforeEach(func() {
			fakeCliConnection = &fakes.FakeCliConnection{}
			callCopyEnvCommandPlugin = &CopyEnv{}
		})

		It("Extract Application Name From Command Line Args", func() {
			name, err := callCopyEnvCommandPlugin.ExtractAppName([]string{"copyenv"})
			Ω(err).Should(MatchError("missing application name"))

			name, err = callCopyEnvCommandPlugin.ExtractAppName([]string{"copyenv", "APP_NAME"})
			Ω(err).ShouldNot(HaveOccurred())
			Ω(name).Should(Equal("APP_NAME"))
		})

		It("Retrieve Application Environment Variables From Name", func() {
			fakeCliConnection.CliCommandWithoutTerminalOutputReturns([]string{"SOME", "OUTPUT", "COMMAND"}, nil)
Example #18
0
package cfcurl_test

import (
	"bufio"
	"errors"
	"os"

	. "github.com/krujos/cfcurl"

	"github.com/cloudfoundry/cli/plugin/fakes"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Cfcurl", func() {
	var fakeCliConnection *fakes.FakeCliConnection

	Describe("an api that is not depricated", func() {
		var v2apps []string

		BeforeEach(func() {
			fakeCliConnection = &fakes.FakeCliConnection{}
			file, err := os.Open("apps.json")
			defer file.Close()
			if err != nil {
				Fail("Could not open apps.json")
			}

			scanner := bufio.NewScanner(file)
			for scanner.Scan() {
				v2apps = append(v2apps, scanner.Text())
import (
	"bytes"
	"errors"
	"strings"

	. "github.com/bluemixgaragelondon/cf-blue-green-deploy"
	"github.com/cloudfoundry/cli/plugin/fakes"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("BlueGreenDeploy", func() {
	var (
		bgdExitsWithErrors []error
		bgdOut             *bytes.Buffer
		connection         *fakes.FakeCliConnection
		p                  BlueGreenDeploy
		testErrorFunc      func(message string, err error)
	)

	BeforeEach(func() {
		bgdExitsWithErrors = []error{}
		testErrorFunc = func(message string, err error) {
			bgdExitsWithErrors = append(bgdExitsWithErrors, err)
		}
		bgdOut = &bytes.Buffer{}

		connection = &fakes.FakeCliConnection{}
		p = BlueGreenDeploy{Connection: connection, ErrorFunc: testErrorFunc, Out: bgdOut}
	})
Example #20
0
			},
		)
		Ω(appName).Should(Equal("appname"))
		Ω(args).Should(Equal([]string{
			"push",
			"appname",
			"-f", "manifest-path",
			"-p", "app-path",
		}))
	})
})

var _ = Describe("Command Syntax", func() {

	var (
		cliConn         *fakes.FakeCliConnection
		autopilotPlugin *AutopilotPlugin
	)

	BeforeEach(func() {
		cliConn = &fakes.FakeCliConnection{}
		autopilotPlugin = &AutopilotPlugin{}
	})

	It("displays push usage when push-zdd called with no arguments", func() {
		autopilotPlugin.Run(cliConn, []string{"push-zdd"})

		Ω(cliConn.CliCommandCallCount()).Should(Equal(1))
		args := cliConn.CliCommandArgsForCall(0)
		Ω(args).Should(Equal([]string{"push", "-h"}))
	})
package application_repo_test

import (
	"errors"

	"github.com/cloudfoundry/cli/plugin/fakes"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	. "github.com/xchapter7x/autopilot/application_repo"
)

var _ = Describe("ApplicationRepo", func() {
	var (
		cliConn *fakes.FakeCliConnection
		repo    *ApplicationRepo
	)

	BeforeEach(func() {
		cliConn = &fakes.FakeCliConnection{}
		repo = NewApplicationRepo(cliConn)
	})

	Describe("RenameApplication", func() {
		It("renames the application", func() {
			err := repo.RenameApplication("old-name", "new-name")
			Ω(err).ShouldNot(HaveOccurred())

			Ω(cliConn.CliCommandCallCount()).Should(Equal(1))
			args := cliConn.CliCommandArgsForCall(0)
			Ω(args).Should(Equal([]string{"rename", "old-name", "new-name"}))
		})
Example #22
0
	"net/url"

	"github.com/cloudfoundry-incubator/diego-ssh/cf-plugin/models/credential"
	"github.com/cloudfoundry-incubator/diego-ssh/cf-plugin/models/info"
	"github.com/cloudfoundry-incubator/diego-ssh/cf-plugin/models/info/info_fakes"
	"github.com/cloudfoundry/cli/plugin/fakes"

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

var _ = Describe("Credential", func() {
	var (
		fakeCliConnection *fakes.FakeCliConnection
		fakeInfoFactory   *info_fakes.FakeInfoFactory
		credFactory       credential.CredentialFactory
	)

	BeforeEach(func() {
		fakeCliConnection = &fakes.FakeCliConnection{}
		fakeCliConnection.IsSSLDisabledReturns(true, nil)
		fakeInfoFactory = &info_fakes.FakeInfoFactory{}
	})

	JustBeforeEach(func() {
		credFactory = credential.NewCredentialFactory(fakeCliConnection, fakeInfoFactory)
	})

	Describe("AuthorizationCode", func() {
		var v2Info info.Info
)

func slurp(filename string) []string {
	var b []string
	file, _ := os.Open(filename)
	defer file.Close()
	scanner := bufio.NewScanner(file)
	for scanner.Scan() {
		b = append(b, scanner.Text())
	}
	return b
}

var _ = Describe("UsageReport", func() {
	var api *APIHelper
	var fakeCliConnection *fakes.FakeCliConnection

	BeforeEach(func() {
		fakeCliConnection = &fakes.FakeCliConnection{}
		api = &APIHelper{}
	})

	Describe("Get orgs", func() {
		var orgsJSON []string

		BeforeEach(func() {
			orgsJSON = slurp("test-data/orgs.json")
		})

		It("should return two orgs", func() {
			fakeCliConnection.CliCommandWithoutTerminalOutputReturns(orgsJSON, nil)
Example #24
0
package models_test

import (
	"encoding/json"
	"errors"

	. "github.com/cloudfoundry-incubator/diego-ssh/cf-plugin/models"
	"github.com/cloudfoundry/cli/plugin/fakes"

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

var _ = Describe("Curl", func() {
	var fakeCliConnection *fakes.FakeCliConnection

	BeforeEach(func() {
		fakeCliConnection = &fakes.FakeCliConnection{}
	})

	Context("with a valid response", func() {
		type MyStruct struct {
			SomeString string
		}

		BeforeEach(func() {
			input := []string{"{", `"somestring": "foo"`, "}"}
			fakeCliConnection.CliCommandWithoutTerminalOutputReturns(input, nil)
		})

		It("unmarshals a successful response", func() {
package droplet_test

import (
	"errors"

	cliFakes "github.com/cloudfoundry/cli/plugin/fakes"
	"github.com/cloudfoundry/cli/plugin/models"
	. "github.com/krujos/download_droplet_plugin/droplet"
	"github.com/krujos/download_droplet_plugin/droplet/fakes"

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

var _ = Describe("CFDroplet", func() {
	var fakeCliConnection *cliFakes.FakeCliConnection
	var droplet *CFDroplet
	var fakeDownloader *fakes.FakeDownloader

	BeforeEach(func() {
		fakeCliConnection = &cliFakes.FakeCliConnection{}
		fakeDownloader = &fakes.FakeDownloader{}
		droplet = NewCFDroplet(fakeCliConnection, fakeDownloader)
		Ω(droplet.Cli).Should(Equal(fakeCliConnection))
		Ω(droplet.GetDownloader()).ShouldNot(BeNil())
	})

	Describe("Getting the app details from cf", func() {
		BeforeEach(func() {
			fakeCliConnection.GetAppReturns(plugin_models.GetAppModel{Guid: "1234"}, nil)
		})
package buildpacks_test

import (
	. "github.com/davidehringer/cf-buildpack-management-plugin/buildpacks"

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

	"github.com/cloudfoundry/cli/plugin/fakes"
)

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

	var cliConnection *fakes.FakeCliConnection

	BeforeEach(func() {
		cliConnection = &fakes.FakeCliConnection{}
	})

	It("it calls the delete-buildpack comand with the 'force' flag", func() {
		command := NewCliDeleteBuildpackCommand(cliConnection, "example-bp")
		command.Execute()

		Expect(cliConnection.CliCommandCallCount()).To(Equal(1))

		args := cliConnection.CliCommandArgsForCall(0)
		Expect(args).To(Equal([]string{"delete-buildpack", "example-bp", "-f"}))
	})

})
package main

import (
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"

	"github.com/cloudfoundry/cli/plugin/fakes"
	"io/ioutil"
)

var _ = Describe("API", func() {
	Describe("StartedApps", func() {
		var cliConnection *fakes.FakeCliConnection

		BeforeEach(func() {
			cliConnection = &fakes.FakeCliConnection{}
		})

		It("Lists app starts apps", func() {
			getAppsJsonPage, _ := ioutil.ReadFile("fixtures/apps.json")
			cliConnection.CliCommandWithoutTerminalOutputReturns([]string{string(getAppsJsonPage)}, nil)

			api := NewCliCcApi(cliConnection)
			apps, _ := api.StartedApps()

			Expect(len(apps)).To(Equal(45))
		})
	})

	Describe("AppStats", func() {
		var cliConnection *fakes.FakeCliConnection
	"github.com/cloudfoundry/cli/plugin/fakes"
	io_helpers "github.com/cloudfoundry/cli/testhelpers/io"
	. "github.com/jtuchscherer/nozzle-plugin"
	"github.com/jtuchscherer/nozzle-plugin/testhelpers"

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

const (
	ACCESS_TOKEN = "access_token"
)

var _ = Describe("NozzlePlugin", func() {
	Describe(".Run", func() {
		var fakeCliConnection *fakes.FakeCliConnection
		var nozzlerCmd *NozzlerCmd
		var fakeFirehose *testhelpers.FakeFirehose

		BeforeEach(func() {
			fakeFirehose = testhelpers.NewFakeFirehose(ACCESS_TOKEN)
			fakeFirehose.SendLog("Log Message")
			fakeFirehose.Start()

			fakeCliConnection = &fakes.FakeCliConnection{}
			fakeCliConnection.AccessTokenReturns(ACCESS_TOKEN, nil)
			fakeCliConnection.DopplerEndpointReturns(fakeFirehose.URL(), nil)
			nozzlerCmd = &NozzlerCmd{}
		})

		AfterEach(func() {