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


Golang SpaceFields.Guid方法代碼示例

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


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

示例1: TestCreateRoute

func TestCreateRoute(t *testing.T) {
	space := cf.SpaceFields{}
	space.Guid = "my-space-guid"
	space.Name = "my-space"
	domain := cf.DomainFields{}
	domain.Guid = "domain-guid"
	domain.Name = "example.com"
	reqFactory := &testreq.FakeReqFactory{
		LoginSuccess:       true,
		TargetedOrgSuccess: true,
		Domain:             cf.Domain{DomainFields: domain},
		Space:              cf.Space{SpaceFields: space},
	}
	routeRepo := &testapi.FakeRouteRepository{}

	ui := callCreateRoute(t, []string{"-n", "host", "my-space", "example.com"}, reqFactory, routeRepo)

	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"Creating route", "host.example.com", "my-org", "my-space", "my-user"},
		{"OK"},
	})

	assert.Equal(t, routeRepo.CreateInSpaceHost, "host")
	assert.Equal(t, routeRepo.CreateInSpaceDomainGuid, "domain-guid")
	assert.Equal(t, routeRepo.CreateInSpaceSpaceGuid, "my-space-guid")

}
開發者ID:nsnt,項目名稱:cli,代碼行數:27,代碼來源:create_route_test.go

示例2: TestUpdateEndpointWhenUrlIsValidHttpsInfoEndpoint

func TestUpdateEndpointWhenUrlIsValidHttpsInfoEndpoint(t *testing.T) {
	configRepo := testconfig.FakeConfigRepository{}
	configRepo.Delete()
	configRepo.Login()

	ts, repo := createEndpointRepoForUpdate(configRepo, validApiInfoEndpoint)
	defer ts.Close()
	org := cf.OrganizationFields{}
	org.Name = "my-org"
	org.Guid = "my-org-guid"

	space := cf.SpaceFields{}
	space.Name = "my-space"
	space.Guid = "my-space-guid"

	config, _ := configRepo.Get()
	config.OrganizationFields = org
	config.SpaceFields = space

	repo.UpdateEndpoint(ts.URL)

	savedConfig := testconfig.SavedConfiguration

	assert.Equal(t, savedConfig.AccessToken, "")
	assert.Equal(t, savedConfig.AuthorizationEndpoint, "https://login.example.com")
	assert.Equal(t, savedConfig.Target, ts.URL)
	assert.Equal(t, savedConfig.ApiVersion, "42.0.0")
	assert.False(t, savedConfig.HasOrganization())
	assert.False(t, savedConfig.HasSpace())
}
開發者ID:pmuellr,項目名稱:cli,代碼行數:30,代碼來源:endpoints_test.go

示例3: TestUpdateEndpointWhenUrlIsAlreadyTargeted

func TestUpdateEndpointWhenUrlIsAlreadyTargeted(t *testing.T) {
	configRepo := testconfig.FakeConfigRepository{}
	configRepo.Delete()
	configRepo.Login()

	ts, repo := createEndpointRepoForUpdate(configRepo, validApiInfoEndpoint)
	defer ts.Close()

	org := cf.OrganizationFields{}
	org.Name = "my-org"
	org.Guid = "my-org-guid"

	space := cf.SpaceFields{}
	space.Name = "my-space"
	space.Guid = "my-space-guid"

	config, _ := configRepo.Get()
	config.Target = ts.URL
	config.AccessToken = "some access token"
	config.RefreshToken = "some refresh token"
	config.OrganizationFields = org
	config.SpaceFields = space

	repo.UpdateEndpoint(ts.URL)

	assert.Equal(t, config.OrganizationFields, org)
	assert.Equal(t, config.SpaceFields, space)
	assert.Equal(t, config.AccessToken, "some access token")
	assert.Equal(t, config.RefreshToken, "some refresh token")
}
開發者ID:pmuellr,項目名稱:cli,代碼行數:30,代碼來源:endpoints_test.go

示例4: createServiceRepo

func createServiceRepo(t *testing.T, reqs []testnet.TestRequest) (ts *httptest.Server, handler *testnet.TestHandler, repo ServiceRepository) {
	space2 := cf.SpaceFields{}
	space2.Guid = "my-space-guid"
	config := &configuration.Configuration{
		AccessToken: "BEARER my_access_token",
		SpaceFields: space2,
	}
	return createServiceRepoWithConfig(t, reqs, config)
}
開發者ID:nsnt,項目名稱:cli,代碼行數:9,代碼來源:services_test.go

示例5: createServiceSummaryRepo

func createServiceSummaryRepo(t *testing.T, req testnet.TestRequest) (ts *httptest.Server, handler *testnet.TestHandler, repo ServiceSummaryRepository) {
	ts, handler = testnet.NewTLSServer(t, []testnet.TestRequest{req})
	space := cf.SpaceFields{}
	space.Guid = "my-space-guid"
	config := &configuration.Configuration{
		AccessToken: "BEARER my_access_token",
		Target:      ts.URL,
		SpaceFields: space,
	}
	gateway := net.NewCloudControllerGateway()
	repo = NewCloudControllerServiceSummaryRepository(config, gateway)
	return
}
開發者ID:pmuellr,項目名稱:cli,代碼行數:13,代碼來源:service_summary_test.go

示例6: TestGetServiceOfferingsWhenTargetingASpace

func TestGetServiceOfferingsWhenTargetingASpace(t *testing.T) {
	req := testapi.NewCloudControllerTestRequest(testnet.TestRequest{
		Method:   "GET",
		Path:     "/v2/spaces/my-space-guid/services?inline-relations-depth=1",
		Response: multipleOfferingsResponse,
	})
	space := cf.SpaceFields{}
	space.Guid = "my-space-guid"
	config := &configuration.Configuration{
		AccessToken: "BEARER my_access_token",
		SpaceFields: space,
	}
	testGetServiceOfferings(t, req, config)
}
開發者ID:nsnt,項目名稱:cli,代碼行數:14,代碼來源:services_test.go

示例7: TestMarketplaceServices

func TestMarketplaceServices(t *testing.T) {
	plan := cf.ServicePlanFields{}
	plan.Name = "service-plan-a"
	plan2 := cf.ServicePlanFields{}
	plan2.Name = "service-plan-b"
	plan3 := cf.ServicePlanFields{}
	plan3.Name = "service-plan-c"
	plan4 := cf.ServicePlanFields{}
	plan4.Name = "service-plan-d"

	offering := cf.ServiceOffering{}
	offering.Label = "zzz-my-service-offering"
	offering.Description = "service offering 1 description"
	offering.Plans = []cf.ServicePlanFields{plan, plan2}

	offering2 := cf.ServiceOffering{}
	offering2.Label = "aaa-my-service-offering"
	offering2.Description = "service offering 2 description"
	offering2.Plans = []cf.ServicePlanFields{plan3, plan4}

	serviceOfferings := []cf.ServiceOffering{offering, offering2}
	serviceRepo := &testapi.FakeServiceRepo{ServiceOfferings: serviceOfferings}

	token, err := testconfig.CreateAccessTokenWithTokenInfo(configuration.TokenInfo{
		Username: "my-user",
	})
	assert.NoError(t, err)
	org := cf.OrganizationFields{}
	org.Name = "my-org"
	org.Guid = "my-org-guid"
	space := cf.SpaceFields{}
	space.Name = "my-space"
	space.Guid = "my-space-guid"
	config := &configuration.Configuration{
		SpaceFields:        space,
		OrganizationFields: org,
		AccessToken:        token,
	}

	ui := callMarketplaceServices(t, config, serviceRepo)
	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"Getting services from marketplace in org", "my-org", "my-space", "my-user"},
		{"OK"},
		{"service", "plans", "description"},
		{"aaa-my-service-offering", "service offering 2 description", "service-plan-c", "service-plan-d"},
		{"zzz-my-service-offering", "service offering 1 description", "service-plan-a", "service-plan-b"},
	})
}
開發者ID:nsnt,項目名稱:cli,代碼行數:48,代碼來源:marketplace_services_test.go

示例8: createRoutesRepo

func createRoutesRepo(t *testing.T, requests ...testnet.TestRequest) (ts *httptest.Server, handler *testnet.TestHandler, repo CloudControllerRouteRepository, domainRepo *testapi.FakeDomainRepository) {
	ts, handler = testnet.NewTLSServer(t, requests)
	space := cf.SpaceFields{}
	space.Guid = "my-space-guid"
	config := &configuration.Configuration{
		AccessToken: "BEARER my_access_token",
		Target:      ts.URL,
		SpaceFields: space,
	}

	gateway := net.NewCloudControllerGateway()
	domainRepo = &testapi.FakeDomainRepository{}

	repo = NewCloudControllerRouteRepository(config, gateway, domainRepo)
	return
}
開發者ID:nsnt,項目名稱:cli,代碼行數:16,代碼來源:routes_test.go

示例9: TestSetSpace

func TestSetSpace(t *testing.T) {
	repo := NewConfigurationDiskRepository()
	repo.loadDefaultConfig(t)
	defer repo.restoreConfig(t)
	space := cf.SpaceFields{}
	space.Name = "my-space"
	space.Guid = "my-space-guid"
	err := repo.SetSpace(space)
	assert.NoError(t, err)

	repo.Save()

	savedConfig, err := repo.Get()
	assert.NoError(t, err)
	assert.Equal(t, savedConfig.SpaceFields, space)
}
開發者ID:pmuellr,項目名稱:cli,代碼行數:16,代碼來源:repository_test.go

示例10: createDomainRepo

func createDomainRepo(t *testing.T, reqs []testnet.TestRequest) (ts *httptest.Server, handler *testnet.TestHandler, repo DomainRepository) {
	ts, handler = testnet.NewTLSServer(t, reqs)
	org := cf.OrganizationFields{}
	org.Guid = "my-org-guid"
	space := cf.SpaceFields{}
	space.Guid = "my-space-guid"

	config := &configuration.Configuration{
		AccessToken:        "BEARER my_access_token",
		Target:             ts.URL,
		SpaceFields:        space,
		OrganizationFields: org,
	}
	gateway := net.NewCloudControllerGateway()
	repo = NewCloudControllerDomainRepository(config, gateway)
	return
}
開發者ID:pmuellr,項目名稱:cli,代碼行數:17,代碼來源:domains_test.go

示例11: TestSetSpace

func TestSetSpace(t *testing.T) {
	withFakeHome(t, func() {
		repo := NewConfigurationDiskRepository()
		repo.Get()
		space := cf.SpaceFields{}
		space.Name = "my-space"
		space.Guid = "my-space-guid"

		err := repo.SetSpace(space)
		assert.NoError(t, err)

		repo.Save()

		savedConfig, err := repo.Get()
		assert.NoError(t, err)
		assert.Equal(t, savedConfig.SpaceFields, space)
	})
}
開發者ID:nsnt,項目名稱:cli,代碼行數:18,代碼來源:repository_test.go

示例12: TestRouteCreator

func TestRouteCreator(t *testing.T) {
	space := cf.SpaceFields{}
	space.Guid = "my-space-guid"
	space.Name = "my-space"
	domain := cf.DomainFields{}
	domain.Guid = "domain-guid"
	domain.Name = "example.com"

	createdRoute := cf.Route{}
	createdRoute.Host = "my-host"
	createdRoute.Guid = "my-route-guid"
	routeRepo := &testapi.FakeRouteRepository{
		CreateInSpaceCreatedRoute: createdRoute,
	}

	ui := new(testterm.FakeUI)
	token, err := testconfig.CreateAccessTokenWithTokenInfo(configuration.TokenInfo{
		Username: "my-user",
	})
	assert.NoError(t, err)
	org := cf.OrganizationFields{}
	org.Name = "my-org"
	config := &configuration.Configuration{
		OrganizationFields: org,
		AccessToken:        token,
	}

	cmd := NewCreateRoute(ui, config, routeRepo)
	route, apiResponse := cmd.CreateRoute("my-host", domain, space)

	assert.Equal(t, route.Guid, createdRoute.Guid)

	assert.True(t, apiResponse.IsSuccessful())

	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"Creating route", "my-host.example.com", "my-org", "my-space", "my-user"},
		{"OK"},
	})

	assert.Equal(t, routeRepo.CreateInSpaceHost, "my-host")
	assert.Equal(t, routeRepo.CreateInSpaceDomainGuid, "domain-guid")
	assert.Equal(t, routeRepo.CreateInSpaceSpaceGuid, "my-space-guid")
}
開發者ID:nsnt,項目名稱:cli,代碼行數:43,代碼來源:create_route_test.go

示例13: TestDeleteSpaceWhenSpaceNotTargeted

func TestDeleteSpaceWhenSpaceNotTargeted(t *testing.T) {
	reqFactory := defaultDeleteSpaceReqFactory()
	spaceRepo := &testapi.FakeSpaceRepository{}
	configRepo := &testconfig.FakeConfigRepository{}

	config, _ := configRepo.Get()
	otherSpace := cf.SpaceFields{}
	otherSpace.Name = "do-not-delete"
	otherSpace.Guid = "do-not-delete-guid"
	config.SpaceFields = otherSpace
	configRepo.Save()

	ui := &testterm.FakeUI{}
	ctxt := testcmd.NewContext("delete", []string{"-f", "space-to-delete"})

	cmd := NewDeleteSpace(ui, config, spaceRepo, configRepo)
	testcmd.RunCommand(cmd, ctxt, reqFactory)

	config, _ = configRepo.Get()
	assert.Equal(t, config.HasSpace(), true)
}
開發者ID:nsnt,項目名稱:cli,代碼行數:21,代碼來源:delete_space_test.go

示例14: callPush

func callPush(t *testing.T, args []string, deps pushDependencies) (ui *testterm.FakeUI) {

	ui = new(testterm.FakeUI)
	ctxt := testcmd.NewContext("push", args)

	token, err := testconfig.CreateAccessTokenWithTokenInfo(configuration.TokenInfo{
		Username: "my-user",
	})
	assert.NoError(t, err)
	org := cf.OrganizationFields{}
	org.Name = "my-org"
	org.Guid = "my-org-guid"
	space := cf.SpaceFields{}
	space.Name = "my-space"
	space.Guid = "my-space-guid"

	config := &configuration.Configuration{
		SpaceFields:        space,
		OrganizationFields: org,
		AccessToken:        token,
	}

	manifestRepo := deps.manifestRepo
	starter := deps.starter
	stopper := deps.stopper
	binder := deps.binder
	appRepo := deps.appRepo
	domainRepo := deps.domainRepo
	routeRepo := deps.routeRepo
	stackRepo := deps.stackRepo
	appBitsRepo := deps.appBitsRepo
	serviceRepo := deps.serviceRepo

	cmd := NewPush(ui, config, manifestRepo, starter, stopper, binder, appRepo, domainRepo, routeRepo, stackRepo, serviceRepo, appBitsRepo)
	reqFactory := &testreq.FakeReqFactory{LoginSuccess: true, TargetedSpaceSuccess: true}
	testcmd.RunCommand(cmd, ctxt, reqFactory)

	return
}
開發者ID:nsnt,項目名稱:cli,代碼行數:39,代碼來源:push_test.go

示例15: TestSpaceRequirement

func TestSpaceRequirement(t *testing.T) {
	ui := new(testterm.FakeUI)
	org := cf.OrganizationFields{}
	org.Name = "my-org"
	org.Guid = "my-org-guid"
	space := cf.SpaceFields{}
	space.Name = "my-space"
	space.Guid = "my-space-guid"
	config := &configuration.Configuration{
		OrganizationFields: org,

		SpaceFields: space,
	}

	req := newTargetedSpaceRequirement(ui, config)
	success := req.Execute()
	assert.True(t, success)

	config.SpaceFields = cf.SpaceFields{}

	req = newTargetedSpaceRequirement(ui, config)
	success = req.Execute()
	assert.False(t, success)
	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"FAILED"},
		{"No space targeted"},
	})

	ui.ClearOutputs()
	config.OrganizationFields = cf.OrganizationFields{}

	req = newTargetedSpaceRequirement(ui, config)
	success = req.Execute()
	assert.False(t, success)
	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"FAILED"},
		{"No org and space targeted"},
	})
}
開發者ID:nsnt,項目名稱:cli,代碼行數:39,代碼來源:targeted_space_test.go


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