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


Golang Application.EnvironmentVars方法代碼示例

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


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

示例1:

		})

		It("fails with usage when not provided with exactly three args", func() {
			requirementsFactory.NewLoginRequirementReturns(requirements.Passing{})
			requirementsFactory.NewTargetedSpaceRequirementReturns(requirements.Passing{})

			runCommand("zomg", "too", "many", "args")
			Expect(ui.Outputs()).To(ContainSubstrings(
				[]string{"Incorrect Usage", "Requires", "arguments"},
			))
		})
	})

	Context("when logged in, a space is targeted and given enough args", func() {
		BeforeEach(func() {
			app.EnvironmentVars = map[string]interface{}{"foo": "bar"}
			applicationReq := new(requirementsfakes.FakeApplicationRequirement)
			applicationReq.GetApplicationReturns(app)
			requirementsFactory.NewApplicationRequirementReturns(applicationReq)
			requirementsFactory.NewLoginRequirementReturns(requirements.Passing{})
			requirementsFactory.NewTargetedSpaceRequirementReturns(requirements.Passing{})
		})

		Context("when it is new", func() {
			It("is created", func() {
				runCommand("my-app", "DATABASE_URL", "mysql://new-example.com/my-db")

				Expect(ui.Outputs()).To(ContainSubstrings(
					[]string{
						"Setting env variable",
						"DATABASE_URL",
開發者ID:fujitsu-cf,項目名稱:cli,代碼行數:31,代碼來源:set_env_test.go

示例2:

		})

		It("fails with usage when not provided with exactly 2 args", func() {
			requirementsFactory.NewLoginRequirementReturns(requirements.Passing{})
			requirementsFactory.NewTargetedSpaceRequirementReturns(requirements.Passing{})
			applicationReq := new(requirementsfakes.FakeApplicationRequirement)
			applicationReq.GetApplicationReturns(app)
			requirementsFactory.NewApplicationRequirementReturns(applicationReq)

			Expect(runCommand("too", "many", "args")).To(BeFalse())
		})
	})

	Context("when logged in, a space is targeted and provided enough args", func() {
		BeforeEach(func() {
			app.EnvironmentVars = map[string]interface{}{"foo": "bar", "DATABASE_URL": "mysql://example.com/my-db"}

			applicationReq := new(requirementsfakes.FakeApplicationRequirement)
			applicationReq.GetApplicationReturns(app)
			requirementsFactory.NewApplicationRequirementReturns(applicationReq)
			requirementsFactory.NewLoginRequirementReturns(requirements.Passing{})
			requirementsFactory.NewTargetedSpaceRequirementReturns(requirements.Passing{})
		})

		It("updates the app and tells the user what happened", func() {
			runCommand("my-app", "DATABASE_URL")

			Expect(ui.Outputs()).To(ContainSubstrings(
				[]string{"Removing env variable", "DATABASE_URL", "my-app", "my-org", "my-space", "my-user"},
				[]string{"OK"},
			))
開發者ID:fujitsu-cf,項目名稱:cli,代碼行數:31,代碼來源:unset_env_test.go

示例3:

				})

				It("sets the health check timeout", func() {
					Expect(runCLIErr).NotTo(HaveOccurred())
					Expect(fakeManifest.HealthCheckTimeoutCallCount()).To(Equal(1))
					name, timeout := fakeManifest.HealthCheckTimeoutArgsForCall(0)
					Expect(name).To(Equal("app-name"))
					Expect(timeout).To(Equal(5))
				})
			})

			Context("when the app has environment vars", func() {
				BeforeEach(func() {
					application.EnvironmentVars = map[string]interface{}{
						"float64-key": float64(5),
						"bool-key":    true,
						"string-key":  "string",
					}
					appSummaryRepo.GetSummaryReturns(application, nil)
				})

				It("sets the env vars", func() {
					Expect(runCLIErr).NotTo(HaveOccurred())
					Expect(fakeManifest.EnvironmentVarsCallCount()).To(Equal(3))
					actuals := map[string]interface{}{}

					for i := 0; i < 3; i++ {
						name, k, v := fakeManifest.EnvironmentVarsArgsForCall(i)
						Expect(name).To(Equal("app-name"))
						actuals[k] = v
					}
開發者ID:fujitsu-cf,項目名稱:cli,代碼行數:31,代碼來源:create_app_manifest_test.go


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