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


Golang Application.Guid方法代碼示例

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


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

示例1: 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
}
開發者ID:nsnt,項目名稱:cli,代碼行數:32,代碼來源:delete_app_test.go

示例2: 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"},
	})
}
開發者ID:nsnt,項目名稱:cli,代碼行數:26,代碼來源:logs_test.go

示例3: 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())
}
開發者ID:pmuellr,項目名稱:cli,代碼行數:35,代碼來源:applications_test.go

示例4: 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")
}
開發者ID:nsnt,項目名稱:cli,代碼行數:31,代碼來源:push_test.go

示例5: 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")
}
開發者ID:nsnt,項目名稱:cli,代碼行數:35,代碼來源:push_test.go

示例6: 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, "")
}
開發者ID:nsnt,項目名稱:cli,代碼行數:27,代碼來源:push_test.go

示例7: 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")
}
開發者ID:nsnt,項目名稱:cli,代碼行數:26,代碼來源:bind_service_test.go

示例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")
}
開發者ID:nsnt,項目名稱:cli,代碼行數:25,代碼來源:unbind_service_test.go

示例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")
}
開發者ID:nsnt,項目名稱:cli,代碼行數:32,代碼來源:set_env_test.go

示例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")
}
開發者ID:nsnt,項目名稱:cli,代碼行數:28,代碼來源:map_route_test.go

示例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")
}
開發者ID:nsnt,項目名稱:cli,代碼行數:34,代碼來源:push_test.go

示例12: 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)
}
開發者ID:nsnt,項目名稱:cli,代碼行數:18,代碼來源:stop_test.go

示例13: 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)
}
開發者ID:nsnt,項目名稱:cli,代碼行數:12,代碼來源:restart_test.go

示例14: TestApplicationStopReturnsUpdatedAppWhenAppIsAlreadyStopped

func TestApplicationStopReturnsUpdatedAppWhenAppIsAlreadyStopped(t *testing.T) {
	appToStop := cf.Application{}
	appToStop.Name = "my-app"
	appToStop.Guid = "my-app-guid"
	appToStop.State = "stopped"
	appRepo := &testapi.FakeApplicationRepository{}
	config := &configuration.Configuration{}
	stopper := NewStop(new(testterm.FakeUI), config, appRepo)
	updatedApp, err := stopper.ApplicationStop(appToStop)

	assert.NoError(t, err)
	assert.Equal(t, appToStop, updatedApp)
}
開發者ID:nsnt,項目名稱:cli,代碼行數:13,代碼來源:stop_test.go

示例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)
}
開發者ID:nsnt,項目名稱:cli,代碼行數:13,代碼來源:stop_test.go


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