func deleteServiceBroker(confirmation string, args []string) (ui *testterm.FakeUI, reqFactory *testreq.FakeReqFactory, repo *testapi.FakeServiceBrokerRepo) {
	serviceBroker := models.ServiceBroker{}
	serviceBroker.Name = "service-broker-to-delete"
	serviceBroker.Guid = "service-broker-to-delete-guid"

	reqFactory = &testreq.FakeReqFactory{LoginSuccess: true}
	repo = &testapi.FakeServiceBrokerRepo{FindByNameServiceBroker: serviceBroker}
	ui = &testterm.FakeUI{
		Inputs: []string{confirmation},
	}
	config := testconfig.NewRepositoryWithDefaults()

	ctxt := testcmd.NewContext("delete-service-broker", args)
	cmd := NewDeleteServiceBroker(ui, config, repo)
	testcmd.RunCommand(cmd, ctxt, reqFactory)
	return
}
		Expect(repo.FindByNameName).To(Equal("service-broker-to-delete"))
		Expect(repo.DeletedServiceBrokerGuid).To(Equal("service-broker-to-delete-guid"))
		Expect(len(ui.Outputs)).To(Equal(2))
		testassert.SliceContains(ui.Prompts, testassert.Lines{
			{"Really delete", "service-broker-to-delete"},
		})

		testassert.SliceContains(ui.Outputs, testassert.Lines{
			{"Deleting service broker", "service-broker-to-delete", "my-user"},
			{"OK"},
		})
	})
	It("TestDeleteWithForceOption", func() {

		serviceBroker := models.ServiceBroker{}
		serviceBroker.Name = "service-broker-to-delete"
		serviceBroker.Guid = "service-broker-to-delete-guid"

		reqFactory := &testreq.FakeReqFactory{LoginSuccess: true}
		repo := &testapi.FakeServiceBrokerRepo{FindByNameServiceBroker: serviceBroker}
		ui := callDeleteServiceBroker([]string{"-f", "service-broker-to-delete"}, reqFactory, repo)

		Expect(repo.FindByNameName).To(Equal("service-broker-to-delete"))
		Expect(repo.DeletedServiceBrokerGuid).To(Equal("service-broker-to-delete-guid"))
		Expect(len(ui.Prompts)).To(Equal(0))
		Expect(len(ui.Outputs)).To(Equal(2))
		testassert.SliceContains(ui.Outputs, testassert.Lines{
			{"Deleting service broker", "service-broker-to-delete", "my-user"},
			{"OK"},
		})
	})
		repo := &testapi.FakeServiceBrokerRepo{}
		args := []string{"arg1", "arg2"}

		requirementsFactory.LoginSuccess = false
		callRenameServiceBroker(args, requirementsFactory, repo)
		Expect(testcmd.CommandDidPassRequirements).To(BeFalse())

		requirementsFactory.LoginSuccess = true
		callRenameServiceBroker(args, requirementsFactory, repo)
		Expect(testcmd.CommandDidPassRequirements).To(BeTrue())
	})
	It("TestRenameServiceBroker", func() {

		requirementsFactory := &testreq.FakeReqFactory{LoginSuccess: true}
		broker := models.ServiceBroker{}
		broker.Name = "my-found-broker"
		broker.Guid = "my-found-broker-guid"
		repo := &testapi.FakeServiceBrokerRepo{
			FindByNameServiceBroker: broker,
		}
		args := []string{"my-broker", "my-new-broker"}

		ui := callRenameServiceBroker(args, requirementsFactory, repo)

		Expect(repo.FindByNameName).To(Equal("my-broker"))

		testassert.SliceContains(ui.Outputs, testassert.Lines{
			{"Renaming service broker", "my-found-broker", "my-new-broker", "my-user"},
			{"OK"},
		})
}
]
}`

		req := testapi.NewCloudControllerTestRequest(testnet.TestRequest{
			Method:   "GET",
			Path:     "/v2/service_brokers?q=name%3Amy-broker",
			Response: testnet.TestResponse{Status: http.StatusOK, Body: responseBody},
		})

		ts, handler, repo := createServiceBrokerRepo(req)
		defer ts.Close()

		foundBroker, apiResponse := repo.FindByName("my-broker")
		expectedBroker := models.ServiceBroker{}
		expectedBroker.Name = "found-name"
		expectedBroker.Url = "http://found.example.com"
		expectedBroker.Username = "******"
		expectedBroker.Password = "******"
		expectedBroker.Guid = "found-guid"

		Expect(handler.AllRequestsCalled()).To(BeTrue())
		Expect(apiResponse.IsSuccessful()).To(BeTrue())
		Expect(foundBroker).To(Equal(expectedBroker))
	})

	It("TestFindServiceBrokerByNameWheNotFound", func() {
		req := testapi.NewCloudControllerTestRequest(testnet.TestRequest{
			Method:   "GET",
			Path:     "/v2/service_brokers?q=name%3Amy-broker",
			Response: testnet.TestResponse{Status: http.StatusOK, Body: `{ "resources": [ ] }`},
		repo := &testapi.FakeServiceBrokerRepo{}
		args := []string{"arg1", "arg2", "arg3", "arg4"}

		reqFactory.LoginSuccess = false
		callUpdateServiceBroker(args, reqFactory, repo)
		Expect(testcmd.CommandDidPassRequirements).To(BeFalse())

		reqFactory.LoginSuccess = true
		callUpdateServiceBroker(args, reqFactory, repo)
		Expect(testcmd.CommandDidPassRequirements).To(BeTrue())
	})
	It("TestUpdateServiceBroker", func() {

		reqFactory := &testreq.FakeReqFactory{LoginSuccess: true}
		broker := models.ServiceBroker{}
		broker.Name = "my-found-broker"
		broker.Guid = "my-found-broker-guid"
		repo := &testapi.FakeServiceBrokerRepo{
			FindByNameServiceBroker: broker,
		}
		args := []string{"my-broker", "new-username", "new-password", "new-url"}

		ui := callUpdateServiceBroker(args, reqFactory, repo)

		Expect(repo.FindByNameName).To(Equal("my-broker"))

		testassert.SliceContains(ui.Outputs, testassert.Lines{
			{"Updating service broker", "my-found-broker", "my-user"},
			{"OK"},
		})