本文整理匯總了Golang中cf.Application.Name方法的典型用法代碼示例。如果您正苦於以下問題:Golang Application.Name方法的具體用法?Golang Application.Name怎麽用?Golang Application.Name使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cf.Application
的用法示例。
在下文中一共展示了Application.Name方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestUpdateRejectsInproperNames
func TestUpdateRejectsInproperNames(t *testing.T) {
baseRequest := testnet.TestRequest{
Method: "PUT",
Path: "/v2/apps/my-app-guid",
Response: testnet.TestResponse{Status: http.StatusOK, Body: "{}"},
}
requests := []testnet.TestRequest{
baseRequest,
baseRequest,
}
ts, _, repo := createAppRepo(t, requests)
defer ts.Close()
app := cf.Application{}
app.Guid = "my-app-guid"
app.Name = "name with space"
createdApp, apiResponse := repo.Update(app.Guid, app.ToParams())
assert.Equal(t, createdApp, cf.Application{})
assert.Contains(t, apiResponse.Message, "App name is invalid")
app.Name = "[email protected]!"
_, apiResponse = repo.Update(app.Guid, app.ToParams())
assert.True(t, apiResponse.IsNotSuccessful())
app.Name = "Valid-Name"
_, apiResponse = repo.Update(app.Guid, app.ToParams())
assert.True(t, apiResponse.IsSuccessful())
app.Name = "name_with_numbers_2"
_, apiResponse = repo.Update(app.Guid, app.ToParams())
assert.True(t, apiResponse.IsSuccessful())
}
示例2: deleteApp
func deleteApp(t *testing.T, confirmation string, args []string) (ui *testterm.FakeUI, reqFactory *testreq.FakeReqFactory, appRepo *testapi.FakeApplicationRepository) {
app := cf.Application{}
app.Name = "app-to-delete"
app.Guid = "app-to-delete-guid"
reqFactory = &testreq.FakeReqFactory{}
appRepo = &testapi.FakeApplicationRepository{ReadApp: app}
ui = &testterm.FakeUI{
Inputs: []string{confirmation},
}
token, err := testconfig.CreateAccessTokenWithTokenInfo(configuration.TokenInfo{
Username: "my-user",
})
assert.NoError(t, err)
org := cf.OrganizationFields{}
org.Name = "my-org"
space := cf.SpaceFields{}
space.Name = "my-space"
config := &configuration.Configuration{
SpaceFields: space,
OrganizationFields: org,
AccessToken: token,
}
ctxt := testcmd.NewContext("delete", args)
cmd := NewDeleteApp(ui, config, appRepo)
testcmd.RunCommand(cmd, ctxt, reqFactory)
return
}
示例3: TestEventsSuccess
func TestEventsSuccess(t *testing.T) {
timestamp, err := time.Parse(TIMESTAMP_FORMAT, "2000-01-01T00:01:11.00-0000")
assert.NoError(t, err)
reqFactory, eventsRepo := getEventsDependencies()
app := cf.Application{}
app.Name = "my-app"
reqFactory.Application = app
eventsRepo.Events = []cf.EventFields{
{
InstanceIndex: 98,
Timestamp: timestamp,
ExitDescription: "app instance exited",
ExitStatus: 78,
},
{
InstanceIndex: 99,
Timestamp: timestamp,
ExitDescription: "app instance was stopped",
ExitStatus: 77,
},
}
ui := callEvents(t, []string{"my-app"}, reqFactory, eventsRepo)
testassert.SliceContains(t, ui.Outputs, testassert.Lines{
{"Getting events for app", "my-app", "my-org", "my-space", "my-user"},
{"time", "instance", "description", "exit status"},
{timestamp.Local().Format(TIMESTAMP_FORMAT), "98", "app instance exited", "78"},
{timestamp.Local().Format(TIMESTAMP_FORMAT), "99", "app instance was stopped", "77"},
})
}
示例4: TestPushingAppWithNoFlagsWhenAppIsAlreadyBoundToDomain
func TestPushingAppWithNoFlagsWhenAppIsAlreadyBoundToDomain(t *testing.T) {
deps := getPushDependencies()
domain := cf.DomainFields{}
domain.Name = "example.com"
existingRoute := cf.RouteSummary{}
existingRoute.Host = "foo"
existingRoute.Domain = domain
existingApp := cf.Application{}
existingApp.Name = "existing-app"
existingApp.Guid = "existing-app-guid"
existingApp.Routes = []cf.RouteSummary{existingRoute}
deps.appRepo.ReadApp = existingApp
deps.appRepo.UpdateAppResult = existingApp
_ = callPush(t, []string{"existing-app"}, deps)
assert.Equal(t, deps.appBitsRepo.UploadedAppGuid, "existing-app-guid")
assert.Equal(t, deps.domainRepo.FindByNameInCurrentSpaceName, "")
assert.Equal(t, deps.routeRepo.FindByHostAndDomainDomain, "")
assert.Equal(t, deps.routeRepo.FindByHostAndDomainHost, "")
assert.Equal(t, deps.routeRepo.CreatedHost, "")
assert.Equal(t, deps.routeRepo.CreatedDomainGuid, "")
}
示例5: TestPushingAppWhenItAlreadyExistsAndDomainIsSpecifiedIsAlreadyBound
func TestPushingAppWhenItAlreadyExistsAndDomainIsSpecifiedIsAlreadyBound(t *testing.T) {
deps := getPushDependencies()
domain := cf.DomainFields{}
domain.Name = "example.com"
domain.Guid = "domain-guid"
existingRoute := cf.RouteSummary{}
existingRoute.Host = "existing-app"
existingRoute.Domain = domain
existingApp := cf.Application{}
existingApp.Name = "existing-app"
existingApp.Guid = "existing-app-guid"
existingApp.Routes = []cf.RouteSummary{existingRoute}
foundRoute := cf.Route{}
foundRoute.RouteFields = existingRoute.RouteFields
foundRoute.Domain = existingRoute.Domain
deps.appRepo.ReadApp = existingApp
deps.appRepo.UpdateAppResult = existingApp
deps.routeRepo.FindByHostAndDomainRoute = foundRoute
ui := callPush(t, []string{"-d", "example.com", "existing-app"}, deps)
testassert.SliceContains(t, ui.Outputs, testassert.Lines{
{"Using route", "existing-app", "example.com"},
})
assert.Equal(t, deps.appBitsRepo.UploadedAppGuid, "existing-app-guid")
}
示例6: TestBindCommand
func TestBindCommand(t *testing.T) {
app := cf.Application{}
app.Name = "my-app"
app.Guid = "my-app-guid"
serviceInstance := cf.ServiceInstance{}
serviceInstance.Name = "my-service"
serviceInstance.Guid = "my-service-guid"
reqFactory := &testreq.FakeReqFactory{
Application: app,
ServiceInstance: serviceInstance,
}
serviceBindingRepo := &testapi.FakeServiceBindingRepo{}
ui := callBindService(t, []string{"my-app", "my-service"}, reqFactory, serviceBindingRepo)
assert.Equal(t, reqFactory.ApplicationName, "my-app")
assert.Equal(t, reqFactory.ServiceInstanceName, "my-service")
assert.Equal(t, len(ui.Outputs), 3)
testassert.SliceContains(t, ui.Outputs, testassert.Lines{
{"Binding service", "my-service", "my-app", "my-org", "my-space", "my-user"},
{"OK"},
{"TIP"},
})
assert.Equal(t, serviceBindingRepo.CreateServiceInstanceGuid, "my-service-guid")
assert.Equal(t, serviceBindingRepo.CreateApplicationGuid, "my-app-guid")
}
示例7: TestPushingAppWhenItAlreadyExistsAndHostIsSpecified
func TestPushingAppWhenItAlreadyExistsAndHostIsSpecified(t *testing.T) {
deps := getPushDependencies()
domain := cf.Domain{}
domain.Name = "example.com"
domain.Guid = "domain-guid"
domain.Shared = true
existingRoute := cf.RouteSummary{}
existingRoute.Host = "existing-app"
existingRoute.Domain = domain.DomainFields
existingApp := cf.Application{}
existingApp.Name = "existing-app"
existingApp.Guid = "existing-app-guid"
existingApp.Routes = []cf.RouteSummary{existingRoute}
deps.appRepo.ReadApp = existingApp
deps.appRepo.UpdateAppResult = existingApp
deps.routeRepo.FindByHostAndDomainNotFound = true
deps.domainRepo.ListSharedDomainsDomains = []cf.Domain{domain}
ui := callPush(t, []string{"-n", "new-host", "existing-app"}, deps)
testassert.SliceContains(t, ui.Outputs, testassert.Lines{
{"Creating route", "new-host.example.com"},
{"OK"},
{"Binding", "new-host.example.com"},
})
assert.Equal(t, deps.routeRepo.FindByHostAndDomainDomain, "example.com")
assert.Equal(t, deps.routeRepo.FindByHostAndDomainHost, "new-host")
assert.Equal(t, deps.routeRepo.CreatedHost, "new-host")
assert.Equal(t, deps.routeRepo.CreatedDomainGuid, "domain-guid")
}
示例8: TestUnbindCommandWhenBindingIsNonExistent
func TestUnbindCommandWhenBindingIsNonExistent(t *testing.T) {
app := cf.Application{}
app.Name = "my-app"
app.Guid = "my-app-guid"
serviceInstance := cf.ServiceInstance{}
serviceInstance.Name = "my-service"
serviceInstance.Guid = "my-service-guid"
reqFactory := &testreq.FakeReqFactory{
Application: app,
ServiceInstance: serviceInstance,
}
serviceBindingRepo := &testapi.FakeServiceBindingRepo{DeleteBindingNotFound: true}
ui := callUnbindService(t, []string{"my-app", "my-service"}, reqFactory, serviceBindingRepo)
assert.Equal(t, reqFactory.ApplicationName, "my-app")
assert.Equal(t, reqFactory.ServiceInstanceName, "my-service")
testassert.SliceContains(t, ui.Outputs, testassert.Lines{
{"Unbinding app", "my-service", "my-app"},
{"OK"},
{"my-service", "my-app", "did not exist"},
})
assert.Equal(t, serviceBindingRepo.DeleteServiceInstance, serviceInstance)
assert.Equal(t, serviceBindingRepo.DeleteApplicationGuid, "my-app-guid")
}
示例9: TestSetEnvWhenItAlreadyExists
func TestSetEnvWhenItAlreadyExists(t *testing.T) {
app := cf.Application{}
app.Name = "my-app"
app.Guid = "my-app-guid"
app.EnvironmentVars = map[string]string{"DATABASE_URL": "mysql://example.com/my-db"}
reqFactory := &testreq.FakeReqFactory{Application: app, LoginSuccess: true, TargetedSpaceSuccess: true}
appRepo := &testapi.FakeApplicationRepository{}
args := []string{"my-app", "DATABASE_URL", "mysql://example2.com/my-db"}
ui := callSetEnv(t, args, reqFactory, appRepo)
assert.Equal(t, len(ui.Outputs), 3)
testassert.SliceContains(t, ui.Outputs, testassert.Lines{
{
"Setting env variable",
"DATABASE_URL",
"mysql://example2.com/my-db",
"my-app",
"my-org",
"my-space",
"my-user",
},
{"OK"},
{"TIP"},
})
assert.Equal(t, reqFactory.ApplicationName, "my-app")
assert.Equal(t, appRepo.UpdateAppGuid, app.Guid)
envParams := appRepo.UpdateParams.Get("env").(generic.Map)
assert.Equal(t, envParams.Get("DATABASE_URL").(string), "mysql://example2.com/my-db")
}
示例10: TestMapRouteWhenBinding
func TestMapRouteWhenBinding(t *testing.T) {
domain := cf.Domain{}
domain.Guid = "my-domain-guid"
domain.Name = "example.com"
route := cf.Route{}
route.Guid = "my-route-guid"
route.Host = "foo"
route.Domain = domain.DomainFields
app := cf.Application{}
app.Guid = "my-app-guid"
app.Name = "my-app"
routeRepo := &testapi.FakeRouteRepository{}
reqFactory := &testreq.FakeReqFactory{LoginSuccess: true, Application: app, Domain: domain}
routeCreator := &testcmd.FakeRouteCreator{ReservedRoute: route}
ui := callMapRoute(t, []string{"-n", "my-host", "my-app", "my-domain.com"}, reqFactory, routeRepo, routeCreator)
testassert.SliceContains(t, ui.Outputs, testassert.Lines{
{"Adding route", "foo.example.com", "my-app", "my-org", "my-space", "my-user"},
{"OK"},
})
assert.Equal(t, routeRepo.BoundRouteGuid, "my-route-guid")
assert.Equal(t, routeRepo.BoundAppGuid, "my-app-guid")
}
示例11: TestPushingAppWhenItAlreadyExistsAndChangingOptions
func TestPushingAppWhenItAlreadyExistsAndChangingOptions(t *testing.T) {
deps := getPushDependencies()
existingRoute := cf.RouteSummary{}
existingRoute.Host = "existing-app"
existingApp := cf.Application{}
existingApp.Name = "existing-app"
existingApp.Guid = "existing-app-guid"
existingApp.Routes = []cf.RouteSummary{existingRoute}
deps.appRepo.ReadApp = existingApp
stack := cf.Stack{}
stack.Name = "differentStack"
stack.Guid = "differentStack-guid"
deps.stackRepo.FindByNameStack = stack
args := []string{
"-c", "different start command",
"-i", "10",
"-m", "1G",
"-b", "https://github.com/heroku/heroku-buildpack-different.git",
"-s", "differentStack",
"existing-app",
}
_ = callPush(t, args, deps)
assert.Equal(t, deps.appRepo.UpdateParams.Get("command"), "different start command")
assert.Equal(t, deps.appRepo.UpdateParams.Get("instances"), 10)
assert.Equal(t, deps.appRepo.UpdateParams.Get("memory"), uint64(1024))
assert.Equal(t, deps.appRepo.UpdateParams.Get("buildpack"), "https://github.com/heroku/heroku-buildpack-different.git")
assert.Equal(t, deps.appRepo.UpdateParams.Get("stack_guid"), "differentStack-guid")
}
示例12: TestLogsOutputsRecentLogs
func TestLogsOutputsRecentLogs(t *testing.T) {
app := cf.Application{}
app.Name = "my-app"
app.Guid = "my-app-guid"
currentTime := time.Now()
recentLogs := []*logmessage.Message{
NewLogMessage("Log Line 1", app.Guid, "DEA", currentTime),
NewLogMessage("Log Line 2", app.Guid, "DEA", currentTime),
}
reqFactory, logsRepo := getLogsDependencies()
reqFactory.Application = app
logsRepo.RecentLogs = recentLogs
ui := callLogs(t, []string{"--recent", "my-app"}, reqFactory, logsRepo)
assert.Equal(t, reqFactory.ApplicationName, "my-app")
assert.Equal(t, app.Guid, logsRepo.AppLoggedGuid)
testassert.SliceContains(t, ui.Outputs, testassert.Lines{
{"Connected, dumping recent logs for app", "my-app", "my-org", "my-space", "my-user"},
{"Log Line 1"},
{"Log Line 2"},
})
}
示例13: TestApplicationStopReturnsUpdatedApp
func TestApplicationStopReturnsUpdatedApp(t *testing.T) {
appToStop := cf.Application{}
appToStop.Name = "my-app"
appToStop.Guid = "my-app-guid"
appToStop.State = "started"
expectedStoppedApp := cf.Application{}
expectedStoppedApp.Name = "my-stopped-app"
expectedStoppedApp.Guid = "my-stopped-app-guid"
expectedStoppedApp.State = "stopped"
appRepo := &testapi.FakeApplicationRepository{UpdateAppResult: expectedStoppedApp}
config := &configuration.Configuration{}
stopper := NewStop(new(testterm.FakeUI), config, appRepo)
actualStoppedApp, err := stopper.ApplicationStop(appToStop)
assert.NoError(t, err)
assert.Equal(t, expectedStoppedApp, actualStoppedApp)
}
示例14: TestRestartApplication
func TestRestartApplication(t *testing.T) {
app := cf.Application{}
app.Name = "my-app"
app.Guid = "my-app-guid"
reqFactory := &testreq.FakeReqFactory{Application: app, LoginSuccess: true, TargetedSpaceSuccess: true}
starter := &testcmd.FakeAppStarter{}
stopper := &testcmd.FakeAppStopper{}
callRestart([]string{"my-app"}, reqFactory, starter, stopper)
assert.Equal(t, stopper.AppToStop, app)
assert.Equal(t, starter.AppToStart, app)
}
示例15: TestStopCommandFailsWithUsage
func TestStopCommandFailsWithUsage(t *testing.T) {
app := cf.Application{}
app.Name = "my-app"
app.Guid = "my-app-guid"
appRepo := &testapi.FakeApplicationRepository{ReadApp: app}
reqFactory := &testreq.FakeReqFactory{Application: app}
ui := callStop(t, []string{}, reqFactory, appRepo)
assert.True(t, ui.FailedWithUsage)
ui = callStop(t, []string{"my-app"}, reqFactory, appRepo)
assert.False(t, ui.FailedWithUsage)
}