func processAppsChan(
	cliConnection api.Connection,
	spaceMap map[string]models.Space,
	migrate migrateAppFunc,
	appsChan chan models.Application,
	maxInFlight int,
	outputSize int) (chan int, *sync.WaitGroup) {
	var waitDone sync.WaitGroup

	output := make(chan int, outputSize)

	diegoSupport := diegosupport.NewDiegoSupport(cliConnection)

	for i := 0; i < maxInFlight; i++ {
		waitDone.Add(1)

		go func() {
			defer waitDone.Done()

			for app := range appsChan {
				a := &displayhelpers.AppPrinter{
					App:    app,
					Spaces: spaceMap,
				}
				output <- migrate(a, diegoSupport)
			}
		}()
	}
	return output, &waitDone
}
func ToggleDiegoSupport(on bool, cliConnection api.Connection, appName string) error {
	d := diegosupport.NewDiegoSupport(cliConnection)

	fmt.Printf("Setting %s Diego support to %t\n", appName, on)
	app, err := cliConnection.GetApp(appName)
	if err != nil {
		return err
	}

	if output, err := d.SetDiegoFlag(app.Guid, on); err != nil {
		return fmt.Errorf("%s\n%s", err, strings.Join(output, "\n"))
	}
	ui.SayOK()

	fmt.Printf("Verifying %s Diego support is set to %t\n", appName, on)
	app, err = cliConnection.GetApp(appName)
	if err != nil {
		return err
	}

	if app.Diego == on {
		ui.SayOK()
	} else {
		return fmt.Errorf("Diego support for %s is NOT set to %t\n\n", appName, on)
	}

	return nil
}
	"github.com/cloudfoundry-incubator/diego-enabler/diegosupport/diegosupportfakes"

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

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

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

	Describe("SetDiegoFlag", func() {
		Context("when constructing the api call", func() {
			It("invokes CliCommandWithoutTerminalOutput()", func() {
				diegoSupport.SetDiegoFlag("123", false)

				Expect(fakeCliConnection.CliCommandWithoutTerminalOutputCallCount()).To(Equal(1))
			})

			It("calls cli core command 'curl'", func() {
				diegoSupport.SetDiegoFlag("123", false)

				Expect(fakeCliConnection.CliCommandWithoutTerminalOutputArgsForCall(0)[0]).To(Equal("curl"))
			})