本文整理匯總了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))
})
}
示例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()
}
})
}
示例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
}
示例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{}
}
示例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,
)
}
})
}
示例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)
}
示例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()
}
})
}
示例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))
示例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))