"code.cloudfoundry.org/cli/cf/terminal" testcmd "code.cloudfoundry.org/cli/testhelpers/commands" testconfig "code.cloudfoundry.org/cli/testhelpers/configuration" testterm "code.cloudfoundry.org/cli/testhelpers/terminal" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "code.cloudfoundry.org/cli/cf/commands/route" . "code.cloudfoundry.org/cli/testhelpers/matchers" ) var _ = Describe("routes command", func() { var ( ui *testterm.FakeUI routeRepo *apifakes.FakeRouteRepository domainRepo *apifakes.FakeDomainRepository configRepo coreconfig.Repository requirementsFactory *requirementsfakes.FakeFactory deps commandregistry.Dependency ) updateCommandDependency := func(pluginCall bool) { deps.UI = ui deps.RepoLocator = deps.RepoLocator.SetRouteRepository(routeRepo).SetDomainRepository(domainRepo) deps.Config = configRepo commandregistry.Commands.SetCommand(commandregistry.Commands.FindCommand("routes").SetDependency(deps, pluginCall)) } BeforeEach(func() { ui = &testterm.FakeUI{} configRepo = testconfig.NewRepositoryWithDefaults() requirementsFactory = new(requirementsfakes.FakeFactory)
testconfig "code.cloudfoundry.org/cli/testhelpers/configuration" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) var _ = Describe("DomainRequirement", func() { var config coreconfig.ReadWriter BeforeEach(func() { config = testconfig.NewRepository() config.SetOrganizationFields(models.OrganizationFields{GUID: "the-org-guid"}) }) It("succeeds when the domain is found", func() { domain := models.DomainFields{Name: "example.com", GUID: "domain-guid"} domainRepo := new(apifakes.FakeDomainRepository) domainRepo.FindByNameInOrgReturns(domain, nil) domainReq := NewDomainRequirement("example.com", config, domainRepo) err := domainReq.Execute() Expect(err).NotTo(HaveOccurred()) orgName, orgGUID := domainRepo.FindByNameInOrgArgsForCall(0) Expect(orgName).To(Equal("example.com")) Expect(orgGUID).To(Equal("the-org-guid")) Expect(domainReq.GetDomain()).To(Equal(domain)) }) It("fails when the domain is not found", func() { domainRepo := new(apifakes.FakeDomainRepository) domainRepo.FindByNameInOrgReturns(models.DomainFields{}, errors.NewModelNotFoundError("Domain", "")) domainReq := NewDomainRequirement("example.com", config, domainRepo)
"code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" testcmd "code.cloudfoundry.org/cli/testhelpers/commands" testconfig "code.cloudfoundry.org/cli/testhelpers/configuration" testterm "code.cloudfoundry.org/cli/testhelpers/terminal" . "code.cloudfoundry.org/cli/testhelpers/matchers" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) var _ = Describe("create domain command", func() { var ( requirementsFactory *requirementsfakes.FakeFactory ui *testterm.FakeUI domainRepo *apifakes.FakeDomainRepository configRepo coreconfig.Repository deps commandregistry.Dependency ) updateCommandDependency := func(pluginCall bool) { deps.UI = ui deps.RepoLocator = deps.RepoLocator.SetDomainRepository(domainRepo) deps.Config = configRepo commandregistry.Commands.SetCommand(commandregistry.Commands.FindCommand("create-domain").SetDependency(deps, pluginCall)) } BeforeEach(func() { requirementsFactory = new(requirementsfakes.FakeFactory) requirementsFactory.NewLoginRequirementReturns(requirements.Passing{}) domainRepo = new(apifakes.FakeDomainRepository)
testterm "code.cloudfoundry.org/cli/testhelpers/terminal" . "code.cloudfoundry.org/cli/testhelpers/matchers" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) var _ = Describe("CheckRoute", func() { var ( ui *testterm.FakeUI configRepo coreconfig.Repository routeRepo *apifakes.FakeRouteRepository domainRepo *apifakes.FakeDomainRepository cmd commandregistry.Command deps commandregistry.Dependency factory *requirementsfakes.FakeFactory flagContext flags.FlagContext loginRequirement requirements.Requirement targetedOrgRequirement *requirementsfakes.FakeTargetedOrgRequirement minAPIVersionRequirement requirements.Requirement ) BeforeEach(func() { ui = &testterm.FakeUI{} configRepo = testconfig.NewRepositoryWithDefaults() routeRepo = new(apifakes.FakeRouteRepository) repoLocator := deps.RepoLocator.SetRouteRepository(routeRepo)
"code.cloudfoundry.org/cli/cf/requirements" "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" testcmd "code.cloudfoundry.org/cli/testhelpers/commands" testconfig "code.cloudfoundry.org/cli/testhelpers/configuration" testterm "code.cloudfoundry.org/cli/testhelpers/terminal" . "code.cloudfoundry.org/cli/testhelpers/matchers" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) var _ = Describe("delete-shared-domain command", func() { var ( ui *testterm.FakeUI domainRepo *apifakes.FakeDomainRepository requirementsFactory *requirementsfakes.FakeFactory configRepo coreconfig.Repository deps commandregistry.Dependency ) updateCommandDependency := func(pluginCall bool) { deps.UI = ui deps.RepoLocator = deps.RepoLocator.SetDomainRepository(domainRepo) deps.Config = configRepo commandregistry.Commands.SetCommand(commandregistry.Commands.FindCommand("delete-shared-domain").SetDependency(deps, pluginCall)) } BeforeEach(func() { ui = &testterm.FakeUI{} domainRepo = new(apifakes.FakeDomainRepository) requirementsFactory = new(requirementsfakes.FakeFactory)
"code.cloudfoundry.org/cli/cf/commands/domain" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) var _ = Describe("ListDomains", func() { var ( ui *testterm.FakeUI routingAPIRepo *apifakes.FakeRoutingAPIRepository domainRepo *apifakes.FakeDomainRepository configRepo coreconfig.Repository cmd domain.ListDomains deps commandregistry.Dependency factory *requirementsfakes.FakeFactory flagContext flags.FlagContext loginRequirement requirements.Requirement targetedOrgRequirement *requirementsfakes.FakeTargetedOrgRequirement domainFields []models.DomainFields routerGroups models.RouterGroups ) BeforeEach(func() { ui = &testterm.FakeUI{} configRepo = testconfig.NewRepositoryWithDefaults() routingAPIRepo = new(apifakes.FakeRoutingAPIRepository) repoLocator := deps.RepoLocator.SetRoutingAPIRepository(routingAPIRepo)
} func (r passingRequirement) Execute() error { return nil } var _ = Describe("CreateSharedDomain", func() { var ( ui *testterm.FakeUI routingAPIRepo *apifakes.FakeRoutingAPIRepository domainRepo *apifakes.FakeDomainRepository configRepo coreconfig.Repository cmd domain.CreateSharedDomain deps commandregistry.Dependency factory *requirementsfakes.FakeFactory flagContext flags.FlagContext loginRequirement requirements.Requirement routingAPIRequirement requirements.Requirement minAPIVersionRequirement requirements.Requirement routerGroups models.RouterGroups ) BeforeEach(func() { ui = &testterm.FakeUI{} configRepo = testconfig.NewRepositoryWithDefaults() routingAPIRepo = new(apifakes.FakeRoutingAPIRepository) repoLocator := deps.RepoLocator.SetRoutingAPIRepository(routingAPIRepo)
"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() {
"code.cloudfoundry.org/cli/cf/requirements" "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" testcmd "code.cloudfoundry.org/cli/testhelpers/commands" testconfig "code.cloudfoundry.org/cli/testhelpers/configuration" testterm "code.cloudfoundry.org/cli/testhelpers/terminal" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" . "code.cloudfoundry.org/cli/testhelpers/matchers" ) var _ = Describe("delete-domain command", func() { var ( ui *testterm.FakeUI configRepo coreconfig.Repository domainRepo *apifakes.FakeDomainRepository requirementsFactory *requirementsfakes.FakeFactory deps commandregistry.Dependency ) updateCommandDependency := func(pluginCall bool) { deps.UI = ui deps.RepoLocator = deps.RepoLocator.SetDomainRepository(domainRepo) deps.Config = configRepo commandregistry.Commands.SetCommand(commandregistry.Commands.FindCommand("delete-domain").SetDependency(deps, pluginCall)) } BeforeEach(func() { ui = &testterm.FakeUI{ Inputs: []string{"yes"}, }