當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Application.GUID方法代碼示例

本文整理匯總了Golang中code/cloudfoundry/org/cli/cf/models.Application.GUID方法的典型用法代碼示例。如果您正苦於以下問題:Golang Application.GUID方法的具體用法?Golang Application.GUID怎麽用?Golang Application.GUID使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在code/cloudfoundry/org/cli/cf/models.Application的用法示例。


在下文中一共展示了Application.GUID方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1:

			{
				Host: "app1",
				Domain: models.DomainFields{
					Name: "example.com",
				},
			}}

		app2Routes := []models.RouteSummary{
			{
				Host:   "app2",
				Domain: models.DomainFields{Name: "cfapps.io"},
			}}

		app := models.Application{}
		app.Name = "Application-1"
		app.GUID = "Application-1-guid"
		app.State = "started"
		app.RunningInstances = 1
		app.InstanceCount = 1
		app.Memory = 512
		app.DiskQuota = 1024
		app.Routes = app1Routes
		app.AppPorts = []int{8080, 9090}

		app2 := models.Application{}
		app2.Name = "Application-2"
		app2.GUID = "Application-2-guid"
		app2.State = "started"
		app2.RunningInstances = 1
		app2.InstanceCount = 2
		app2.Memory = 256
開發者ID:fujitsu-cf,項目名稱:cli,代碼行數:31,代碼來源:apps_test.go

示例2:

	BeforeEach(func() {
		appName = "fake-app-name"
		appRepo = new(applicationsfakes.FakeRepository)
		req = requirements.NewDEAApplicationRequirement(appName, appRepo)
	})

	Describe("GetApplication", func() {
		It("returns an empty application", func() {
			Expect(req.GetApplication()).To(Equal(models.Application{}))
		})

		Context("when the requirement has been executed", func() {
			BeforeEach(func() {
				app := models.Application{}
				app.GUID = "fake-app-guid"
				appRepo.ReadReturns(app, nil)

				req.Execute()
			})

			It("returns the application", func() {
				Expect(req.GetApplication().GUID).To(Equal("fake-app-guid"))
			})
		})
	})

	Describe("Execute", func() {
		Context("when the returned application is a Diego application", func() {
			BeforeEach(func() {
				app := models.Application{}
開發者ID:fujitsu-cf,項目名稱:cli,代碼行數:30,代碼來源:dea_application_test.go

示例3:

	runCommand := func(args ...string) bool {
		return testcmd.RunCLICommand("restart", args, requirementsFactory, updateCommandDependency, false, ui)
	}

	BeforeEach(func() {
		ui = &testterm.FakeUI{}
		deps = commandregistry.NewDependency(os.Stdout, new(tracefakes.FakePrinter), "")
		requirementsFactory = new(requirementsfakes.FakeFactory)
		starter = new(applicationfakes.FakeStarter)
		stopper = new(applicationfakes.FakeStopper)
		config = testconfig.NewRepositoryWithDefaults()

		app = models.Application{}
		app.Name = "my-app"
		app.GUID = "my-app-guid"

		applicationReq = new(requirementsfakes.FakeApplicationRequirement)
		applicationReq.GetApplicationReturns(app)

		//save original command and restore later
		originalStart = commandregistry.Commands.FindCommand("start")
		originalStop = commandregistry.Commands.FindCommand("stop")

		//setup fakes to correctly interact with commandregistry
		starter.SetDependencyStub = func(_ commandregistry.Dependency, _ bool) commandregistry.Command {
			return starter
		}
		starter.MetaDataReturns(commandregistry.CommandMetadata{Name: "start"})

		stopper.SetDependencyStub = func(_ commandregistry.Dependency, _ bool) commandregistry.Command {
開發者ID:fujitsu-cf,項目名稱:cli,代碼行數:30,代碼來源:restart_test.go

示例4:

		flagContext = flags.NewFlagContext(cmd.MetaData().Flags)

		factory = new(requirementsfakes.FakeFactory)

		loginRequirement = &passingRequirement{Name: "login-requirement"}
		factory.NewLoginRequirementReturns(loginRequirement)

		targetedSpaceRequirement = &passingRequirement{}
		factory.NewTargetedSpaceRequirementReturns(targetedSpaceRequirement)

		deaApplicationRequirement = new(requirementsfakes.FakeDEAApplicationRequirement)
		factory.NewDEAApplicationRequirementReturns(deaApplicationRequirement)
		app := models.Application{}
		app.InstanceCount = 1
		app.GUID = "app-guid"
		app.Name = "app-name"
		deaApplicationRequirement.GetApplicationReturns(app)
	})

	Describe("Requirements", func() {
		Context("when not provided one or two args", func() {
			BeforeEach(func() {
				flagContext.Parse("app-name", "the-path", "extra-arg")
			})

			It("fails with usage", func() {
				_, err := cmd.Requirements(factory, flagContext)
				Expect(err).To(HaveOccurred())
				Expect(ui.Outputs()).To(ContainSubstrings(
					[]string{"FAILED"},
開發者ID:fujitsu-cf,項目名稱:cli,代碼行數:30,代碼來源:files_test.go

示例5:

		})

	})

	Describe("ssh", func() {
		var (
			currentApp models.Application
		)

		BeforeEach(func() {
			requirementsFactory.NewLoginRequirementReturns(requirements.Passing{})
			requirementsFactory.NewTargetedSpaceRequirementReturns(requirements.Passing{})
			currentApp = models.Application{}
			currentApp.Name = "my-app"
			currentApp.State = "started"
			currentApp.GUID = "my-app-guid"
			currentApp.EnableSSH = true
			currentApp.Diego = true

			applicationReq := new(requirementsfakes.FakeApplicationRequirement)
			applicationReq.GetApplicationReturns(currentApp)
			requirementsFactory.NewApplicationRequirementReturns(applicationReq)
		})

		Describe("Error getting required info to run ssh", func() {
			var (
				testServer *httptest.Server
				handler    *testnet.TestHandler
			)

			AfterEach(func() {
開發者ID:fujitsu-cf,項目名稱:cli,代碼行數:31,代碼來源:ssh_test.go

示例6:

		application         models.Application
		deps                commandregistry.Dependency
	)

	BeforeEach(func() {

		ui = &testterm.FakeUI{}
		appInstancesRepo = new(appinstancesfakes.FakeAppInstancesRepository)
		config = testconfig.NewRepositoryWithDefaults()
		requirementsFactory = new(requirementsfakes.FakeFactory)
		requirementsFactory.NewLoginRequirementReturns(requirements.Passing{})
		requirementsFactory.NewTargetedSpaceRequirementReturns(requirements.Passing{})

		application = models.Application{}
		application.Name = "my-app"
		application.GUID = "my-app-guid"
		application.InstanceCount = 1
		applicationReq := new(requirementsfakes.FakeApplicationRequirement)
		applicationReq.GetApplicationReturns(application)
		requirementsFactory.NewApplicationRequirementReturns(applicationReq)
	})

	updateCommandDependency := func(pluginCall bool) {
		deps.UI = ui
		deps.Config = config
		deps.RepoLocator = deps.RepoLocator.SetAppInstancesRepository(appInstancesRepo)
		commandregistry.Commands.SetCommand(commandregistry.Commands.FindCommand("restart-app-instance").SetDependency(deps, pluginCall))
	}

	runCommand := func(args ...string) bool {
		return testcmd.RunCLICommand("restart-app-instance", args, requirementsFactory, updateCommandDependency, false, ui)
開發者ID:fujitsu-cf,項目名稱:cli,代碼行數:31,代碼來源:restart_app_instance_test.go

示例7:

		cmd = &route.UnmapRoute{}
		cmd.SetDependency(deps, false)

		flagContext = flags.NewFlagContext(cmd.MetaData().Flags)

		factory = new(requirementsfakes.FakeFactory)

		loginRequirement = &passingRequirement{Name: "login-requirement"}
		factory.NewLoginRequirementReturns(loginRequirement)

		applicationRequirement = new(requirementsfakes.FakeApplicationRequirement)
		factory.NewApplicationRequirementReturns(applicationRequirement)

		fakeApplication := models.Application{}
		fakeApplication.GUID = "fake-app-guid"
		applicationRequirement.GetApplicationReturns(fakeApplication)

		domainRequirement = new(requirementsfakes.FakeDomainRequirement)
		factory.NewDomainRequirementReturns(domainRequirement)

		fakeDomain = models.DomainFields{
			GUID: "fake-domain-guid",
			Name: "fake-domain-name",
		}
		domainRequirement.GetDomainReturns(fakeDomain)

		minAPIVersionRequirement = &passingRequirement{Name: "min-api-version-requirement"}
		factory.NewMinAPIVersionRequirementReturns(minAPIVersionRequirement)
	})
開發者ID:fujitsu-cf,項目名稱:cli,代碼行數:29,代碼來源:unmap_route_test.go

示例8:

	Describe("InteractiveSession", func() {
		var opts *options.SSHOptions
		var sessionError error
		var interactiveSessionInvoker func(secureShell sshCmd.SecureShell)

		BeforeEach(func() {
			sshEndpoint = "ssh.example.com:22"

			opts = &options.SSHOptions{
				AppName: "app-name",
				Index:   2,
			}

			currentApp.State = "STARTED"
			currentApp.Diego = true
			currentApp.GUID = "app-guid"
			token = "bearer token"

			interactiveSessionInvoker = func(secureShell sshCmd.SecureShell) {
				sessionError = secureShell.InteractiveSession()
			}
		})

		JustBeforeEach(func() {
			connectErr := secureShell.Connect(opts)
			Expect(connectErr).NotTo(HaveOccurred())
			interactiveSessionInvoker(secureShell)
		})

		It("dials the correct endpoint as the correct user", func() {
			Expect(fakeSecureDialer.DialCallCount()).To(Equal(1))
開發者ID:fujitsu-cf,項目名稱:cli,代碼行數:31,代碼來源:ssh_test.go

示例9:

	It("fails with usage when the app cannot be found", func() {
		appRepo.ReadReturns(models.Application{}, errors.NewModelNotFoundError("app", "hocus-pocus"))
		runCommand("hocus-pocus")

		Expect(ui.Outputs()).To(ContainSubstrings(
			[]string{"FAILED"},
			[]string{"not found"},
		))
	})

	Context("when the app has at least one env var", func() {
		BeforeEach(func() {
			app = models.Application{}
			app.Name = "my-app"
			app.GUID = "the-app-guid"

			appRepo.ReadReturns(app, nil)
			appRepo.ReadEnvReturns(&models.Environment{
				Environment: map[string]interface{}{
					"my-key":     "my-value",
					"my-key2":    "my-value2",
					"first-key":  0,
					"first-bool": false,
				},
				System: map[string]interface{}{
					"VCAP_SERVICES": map[string]interface{}{
						"pump-yer-brakes": "drive-slow",
					},
				},
				Application: map[string]interface{}{
開發者ID:fujitsu-cf,項目名稱:cli,代碼行數:30,代碼來源:env_test.go

示例10:

							},
							"entity": {
									"name": "my-cool-app"
							}
					}`),
					),
				)
			})

			It("returns the application", func() {
				createdApp, err := repo.Create(appParams)
				Expect(err).NotTo(HaveOccurred())

				app := models.Application{}
				app.Name = "my-cool-app"
				app.GUID = "my-cool-app-guid"
				Expect(createdApp).To(Equal(app))
			})
		})

		Context("when the create fails", func() {
			BeforeEach(func() {
				h := ccServer.GetHandler(0)
				ccServer.SetHandler(0,
					ghttp.CombineHandlers(
						h,
						ghttp.RespondWith(http.StatusInternalServerError, ""),
					),
				)
			})
開發者ID:fujitsu-cf,項目名稱:cli,代碼行數:30,代碼來源:applications_test.go

示例11:

		requirementsFactory *requirementsfakes.FakeFactory
		deps                commandregistry.Dependency
	)

	updateCommandDependency := func(pluginCall bool) {
		deps.UI = ui
		deps.Config = configRepo
		deps.RepoLocator = deps.RepoLocator.SetApplicationRepository(appRepo)
		deps.RepoLocator = deps.RepoLocator.SetRouteRepository(routeRepo)
		commandregistry.Commands.SetCommand(commandregistry.Commands.FindCommand("delete").SetDependency(deps, pluginCall))
	}

	BeforeEach(func() {
		app = models.Application{}
		app.Name = "app-to-delete"
		app.GUID = "app-to-delete-guid"

		ui = &testterm.FakeUI{}
		appRepo = new(applicationsfakes.FakeRepository)
		routeRepo = new(apifakes.FakeRouteRepository)
		requirementsFactory = new(requirementsfakes.FakeFactory)

		configRepo = testconfig.NewRepositoryWithDefaults()
	})

	runCommand := func(args ...string) bool {
		return testcmd.RunCLICommand("delete", args, requirementsFactory, updateCommandDependency, false, ui)
	}

	It("fails requirements when not logged in", func() {
		requirementsFactory.NewUsageRequirementReturns(requirements.Passing{})
開發者ID:fujitsu-cf,項目名稱:cli,代碼行數:31,代碼來源:delete_test.go

示例12:

		cmd = &commands.CreateAppManifest{}
		cmd.SetDependency(deps, false)

		flagContext = flags.NewFlagContext(cmd.MetaData().Flags)
		factory = new(requirementsfakes.FakeFactory)

		loginRequirement = &passingRequirement{Name: "login-requirement"}
		factory.NewLoginRequirementReturns(loginRequirement)

		targetedSpaceRequirement = &passingRequirement{Name: "targeted-space-requirement"}
		factory.NewTargetedSpaceRequirementReturns(targetedSpaceRequirement)

		applicationRequirement = new(requirementsfakes.FakeApplicationRequirement)
		application := models.Application{}
		application.GUID = "app-guid"
		applicationRequirement.GetApplicationReturns(application)
		factory.NewApplicationRequirementReturns(applicationRequirement)
	})

	Describe("Requirements", func() {
		Context("when not provided exactly one arg", func() {
			BeforeEach(func() {
				flagContext.Parse("app-name", "extra-arg")
			})

			It("fails with usage", func() {
				_, err := cmd.Requirements(factory, flagContext)
				Expect(err).To(HaveOccurred())
				Expect(ui.Outputs()).To(ContainSubstrings(
					[]string{"FAILED"},
開發者ID:fujitsu-cf,項目名稱:cli,代碼行數:30,代碼來源:create_app_manifest_test.go


注:本文中的code/cloudfoundry/org/cli/cf/models.Application.GUID方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。