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


Golang cf.ApiRequest函數代碼示例

本文整理匯總了Golang中github.com/cloudfoundry-incubator/cf-test-helpers/cf.ApiRequest函數的典型用法代碼示例。如果您正苦於以下問題:Golang ApiRequest函數的具體用法?Golang ApiRequest怎麽用?Golang ApiRequest使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


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

示例1: Setup

func (context *ConfiguredContext) Setup() {
	cf.AsUser(context.AdminUserContext(), func() {
		channel := cf.Cf("create-user", context.regularUserUsername, context.regularUserPassword)
		select {
		case <-channel.Out.Detect("OK"):
		case <-channel.Out.Detect("scim_resource_already_exists"):
		case <-time.After(ScaledTimeout(10 * time.Second)):
			Fail("failed to create user")
		}

		definition := quotaDefinition{
			Name: context.quotaDefinitionName,

			TotalServices: 100,
			TotalRoutes:   1000,

			MemoryLimit: 10240,

			NonBasicServicesAllowed: true,
		}

		definitionPayload, err := json.Marshal(definition)
		Expect(err).ToNot(HaveOccurred())

		var response cf.GenericResource

		cf.ApiRequest("POST", "/v2/quota_definitions", &response, string(definitionPayload))

		context.quotaDefinitionGUID = response.Metadata.Guid

		Eventually(cf.Cf("create-org", context.organizationName), ScaledTimeout(60*time.Second)).Should(Exit(0))
		Eventually(cf.Cf("set-quota", context.organizationName, definition.Name), ScaledTimeout(60*time.Second)).Should(Exit(0))
	})
}
開發者ID:shalako,項目名稱:cf-mysql-release,代碼行數:34,代碼來源:context.go

示例2: Teardown

func (c *context) Teardown() {

	userOrg := c.RegularUserContext().Org

	cf.RestoreUserContext(c.RegularUserContext(), c.shortTimeout, c.originalCfHomeDir, c.currentCfHomeDir)

	cf.AsUser(c.AdminUserContext(), c.shortTimeout, func() {
		runner.NewCmdRunner(cf.Cf("delete-user", "-f", c.regularUserUsername), c.longTimeout).Run()

		// delete-space does not provide an org flag, so we must target the Org first
		runner.NewCmdRunner(cf.Cf("target", "-o", userOrg), c.longTimeout).Run()
		runner.NewCmdRunner(cf.Cf("delete-space", "-f", c.spaceName), c.longTimeout).Run()

		if !c.useExistingOrg {
			runner.NewCmdRunner(cf.Cf("delete-org", "-f", c.organizationName), c.longTimeout).Run()

			cf.ApiRequest(
				"DELETE",
				"/v2/quota_definitions/"+c.quotaDefinitionGUID+"?recursive=true",
				nil,
				c.ShortTimeout(),
			)
		}

		if c.config.CreatePermissiveSecurityGroup {
			runner.NewCmdRunner(cf.Cf("delete-security-group", "-f", c.securityGroupName), c.shortTimeout).Run()
		}
	})
}
開發者ID:ekcasey,項目名稱:cf-test-helpers,代碼行數:29,代碼來源:context.go

示例3: lastPageUsageEvents

func lastPageUsageEvents(appName string) []AppUsageEvent {
	var response AppUsageEvents

	cf.AsUser(context.AdminUserContext(), DEFAULT_TIMEOUT, func() {
		cf.ApiRequest("GET", "/v2/app_usage_events?order-direction=desc&page=1", &response, DEFAULT_TIMEOUT)
	})

	return response.Resources
}
開發者ID:naheedmk,項目名稱:cf-acceptance-tests,代碼行數:9,代碼來源:app_lifecycle_test.go

示例4: lastAppUsageEvent

func lastAppUsageEvent(appName string, state string) (bool, AppUsageEvent) {
	var response AppUsageEvents
	cf.AsUser(context.AdminUserContext(), DEFAULT_TIMEOUT, func() {
		cf.ApiRequest("GET", "/v2/app_usage_events?order-direction=desc&page=1&results-per-page=150", &response, DEFAULT_TIMEOUT)
	})

	for _, event := range response.Resources {
		if event.Entity.AppName == appName && event.Entity.State == state {
			return true, event
		}
	}

	return false, AppUsageEvent{}
}
開發者ID:cwlbraa,項目名稱:cf-acceptance-tests,代碼行數:14,代碼來源:lifecycle_test.go

示例5: Teardown

func (context *ConfiguredContext) Teardown() {
	cf.AsUser(context.AdminUserContext(), func() {
		Eventually(cf.Cf("delete-user", "-f", context.regularUserUsername), ScaledTimeout(60*time.Second)).Should(Exit(0))

		if !context.isPersistent {
			Eventually(cf.Cf("delete-org", "-f", context.organizationName), ScaledTimeout(60*time.Second)).Should(Exit(0))

			cf.ApiRequest(
				"DELETE",
				"/v2/quota_definitions/"+context.quotaDefinitionGUID+"?recursive=true",
				nil,
			)
		}
	})
}
開發者ID:shalako,項目名稱:cf-mysql-release,代碼行數:15,代碼來源:context.go

示例6: Setup

func (c *context) Setup() {
	cf.AsUser(c.AdminUserContext(), c.shortTimeout, func() {
		runner.NewCmdRunner(cf.Cf("create-user", c.regularUserUsername, c.regularUserPassword), c.shortTimeout).Run()

		if c.useExistingOrg == false {

			definition := QuotaDefinition{
				Name: c.quotaDefinitionName,

				TotalServices: 100,
				TotalRoutes:   1000,

				MemoryLimit: 10240,

				NonBasicServicesAllowed: true,
			}

			definitionPayload, err := json.Marshal(definition)
			gomega.Expect(err).ToNot(gomega.HaveOccurred())

			var response cf.GenericResource
			cf.ApiRequest("POST", "/v2/quota_definitions", &response, c.shortTimeout, string(definitionPayload))

			c.quotaDefinitionGUID = response.Metadata.Guid

			runner.NewCmdRunner(cf.Cf("create-org", c.organizationName), c.shortTimeout).Run()
			runner.NewCmdRunner(cf.Cf("set-quota", c.organizationName, c.quotaDefinitionName), c.shortTimeout).Run()
		}

		c.setUpSpaceWithUserAccess(c.RegularUserContext())

		if c.config.CreatePermissiveSecurityGroup {
			c.createPermissiveSecurityGroup()
		}
	})

	c.originalCfHomeDir, c.currentCfHomeDir = cf.InitiateUserContext(c.RegularUserContext(), c.shortTimeout)
	cf.TargetSpace(c.RegularUserContext(), c.shortTimeout)
}
開發者ID:ekcasey,項目名稱:cf-test-helpers,代碼行數:39,代碼來源:context.go

示例7: Teardown

func (c *context) Teardown() {
	cf.RestoreUserContext(c.RegularUserContext(), c.shortTimeout, c.originalCfHomeDir, c.currentCfHomeDir)

	cf.AsUser(c.AdminUserContext(), c.shortTimeout, func() {
		runner.NewCmdRunner(cf.Cf("delete-user", "-f", c.regularUserUsername), c.longTimeout).Run()

		if !c.isPersistent {
			runner.NewCmdRunner(cf.Cf("delete-org", "-f", c.organizationName), c.longTimeout).Run()

			cf.ApiRequest(
				"DELETE",
				"/v2/quota_definitions/"+c.quotaDefinitionGUID+"?recursive=true",
				nil,
				c.ShortTimeout(),
			)
		}

		if c.config.CreatePermissiveSecurityGroup {
			runner.NewCmdRunner(cf.Cf("delete-security-group", "-f", c.securityGroupName), c.shortTimeout).Run()
		}
	})
}
開發者ID:stefanschneider,項目名稱:diego-windows-msi,代碼行數:22,代碼來源:context.go

示例8:

				"-p", assets.NewAssets().Dora,
				"-d", helpers.LoadConfig().AppsDomain,
				"-c", "FOO=foo bundle exec rackup config.ru -p $PORT",
			).Wait(DEFAULT_TIMEOUT)).To(Exit(0))
			app_helpers.SetBackend(appName)
			Expect(cf.Cf("start", appName).Wait(CF_PUSH_TIMEOUT)).To(Exit(0))
		})

		It("takes effect after a restart, not requiring a push", func() {
			Eventually(func() string {
				return helpers.CurlApp(appName, "/env/FOO")
			}, DEFAULT_TIMEOUT).Should(ContainSubstring("foo"))

			var response cf.QueryResponse

			cf.ApiRequest("GET", "/v2/apps?q=name:"+appName, &response, DEFAULT_TIMEOUT)

			Expect(response.Resources).To(HaveLen(1))

			appGuid := response.Resources[0].Metadata.Guid

			cf.ApiRequest(
				"PUT",
				"/v2/apps/"+appGuid,
				nil,
				DEFAULT_TIMEOUT,
				`{"command":"FOO=bar bundle exec rackup config.ru -p $PORT"}`,
			)

			Expect(cf.Cf("stop", appName).Wait(DEFAULT_TIMEOUT)).To(Exit(0))
開發者ID:cf-routing,項目名稱:cf-acceptance-tests,代碼行數:30,代碼來源:changing_start_command_test.go

示例9:

	}

	itDoesNotDetectForEmptyApp := func() {
		Expect(cf.Cf("push", appName, "--no-start", "-m", DEFAULT_MEMORY_LIMIT, "-p", appPath, "-d", config.AppsDomain).Wait(DEFAULT_TIMEOUT)).To(Exit(0))
		app_helpers.SetBackend(appName)

		start := cf.Cf("start", appName).Wait(CF_PUSH_TIMEOUT)
		Expect(start).To(Exit(1))
		Expect(start).To(Say("NoAppDetectedError"))
	}

	itDoesNotDetectWhenBuildpackDisabled := func() {
		cf.AsUser(context.AdminUserContext(), DEFAULT_TIMEOUT, func() {
			var response cf.QueryResponse

			cf.ApiRequest("GET", "/v2/buildpacks?q=name:"+BuildpackName, &response, DEFAULT_TIMEOUT)

			Expect(response.Resources).To(HaveLen(1))

			buildpackGuid := response.Resources[0].Metadata.Guid

			cf.ApiRequest(
				"PUT",
				"/v2/buildpacks/"+buildpackGuid,
				nil,
				DEFAULT_TIMEOUT,
				`{"enabled":false}`,
			)
		})

		Expect(cf.Cf("push", appName, "--no-start", "-m", DEFAULT_MEMORY_LIMIT, "-p", appPath, "-d", config.AppsDomain).Wait(DEFAULT_TIMEOUT)).To(Exit(0))
開發者ID:cwlbraa,項目名稱:cf-acceptance-tests,代碼行數:31,代碼來源:admin_buildpack_lifecycle_test.go


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