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


Golang Organization.Name方法代碼示例

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


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

示例1: TestListAllPagesOfOrgs

func TestListAllPagesOfOrgs(t *testing.T) {
	org1 := cf.Organization{}
	org1.Name = "Organization-1"

	org2 := cf.Organization{}
	org2.Name = "Organization-2"

	org3 := cf.Organization{}
	org3.Name = "Organization-3"

	orgRepo := &testapi.FakeOrgRepository{
		Organizations: []cf.Organization{org1, org2, org3},
	}

	reqFactory := &testreq.FakeReqFactory{LoginSuccess: true}

	tokenInfo := configuration.TokenInfo{Username: "my-user"}
	accessToken, err := testconfig.CreateAccessTokenWithTokenInfo(tokenInfo)
	assert.NoError(t, err)
	config := &configuration.Configuration{AccessToken: accessToken}

	ui := callListOrgs(config, reqFactory, orgRepo)

	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"Getting orgs as my-user"},
		{"Organization-1"},
		{"Organization-2"},
		{"Organization-3"},
	})
}
開發者ID:nsnt,項目名稱:cli,代碼行數:30,代碼來源:list_orgs_test.go

示例2: TestSuccessfullyLoggingInWithNumericalPrompts

func TestSuccessfullyLoggingInWithNumericalPrompts(t *testing.T) {
	OUT_OF_RANGE_CHOICE := "3"
	c := LoginTestContext{
		Inputs: []string{"api.example.com", "[email protected]", "password", OUT_OF_RANGE_CHOICE, "2", OUT_OF_RANGE_CHOICE, "1"},
	}

	org1 := cf.Organization{}
	org1.Guid = "some-org-guid"
	org1.Name = "some-org"

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

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

	space2 := cf.Space{}
	space2.Guid = "some-space-guid"
	space2.Name = "some-space"

	callLogin(t, &c, func(c *LoginTestContext) {
		c.orgRepo.Organizations = []cf.Organization{org1, org2}
		c.spaceRepo.Spaces = []cf.Space{space1, space2}
	})

	savedConfig := testconfig.SavedConfiguration

	expectedOutputs := testassert.Lines{
		testassert.Line{"Select an org:"},
		testassert.Line{"1. some-org"},
		testassert.Line{"2. my-org"},
		testassert.Line{"Select a space:"},
		testassert.Line{"1. my-space"},
		testassert.Line{"2. some-space"},
	}

	testassert.SliceContains(t, c.ui.Outputs, expectedOutputs)

	assert.Equal(t, savedConfig.Target, "api.example.com")
	assert.Equal(t, savedConfig.OrganizationFields.Guid, "my-org-guid")
	assert.Equal(t, savedConfig.SpaceFields.Guid, "my-space-guid")
	assert.Equal(t, savedConfig.AccessToken, "my_access_token")
	assert.Equal(t, savedConfig.RefreshToken, "my_refresh_token")

	assert.Equal(t, c.endpointRepo.UpdateEndpointReceived, "api.example.com")
	assert.Equal(t, c.authRepo.Email, "[email protected]")
	assert.Equal(t, c.authRepo.Password, "password")

	assert.Equal(t, c.orgRepo.FindByNameName, "my-org")
	assert.Equal(t, c.spaceRepo.FindByNameName, "my-space")

	assert.True(t, c.ui.ShowConfigurationCalled)
}
開發者ID:nsnt,項目名稱:cli,代碼行數:55,代碼來源:login_test.go

示例3: TestTargetOrganizationWhenUserHasAccess

func TestTargetOrganizationWhenUserHasAccess(t *testing.T) {
	orgRepo, spaceRepo, configRepo, reqFactory := getTargetDependencies()

	configRepo.Login()
	config, err := configRepo.Get()
	assert.NoError(t, err)

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

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

	orgRepo.Organizations = []cf.Organization{org}
	orgRepo.FindByNameOrganization = org

	ui := callTarget([]string{"-o", "my-organization"}, reqFactory, configRepo, orgRepo, spaceRepo)

	assert.Equal(t, orgRepo.FindByNameName, "my-organization")
	assert.True(t, ui.ShowConfigurationCalled)

	savedConfig := testconfig.SavedConfiguration
	assert.Equal(t, savedConfig.OrganizationFields.Guid, "my-organization-guid")
}
開發者ID:nsnt,項目名稱:cli,代碼行數:26,代碼來源:target_test.go

示例4: TestRunWhenOrganizationExists

func TestRunWhenOrganizationExists(t *testing.T) {
	developmentSpaceFields := cf.SpaceFields{}
	developmentSpaceFields.Name = "development"
	stagingSpaceFields := cf.SpaceFields{}
	stagingSpaceFields.Name = "staging"
	domainFields := cf.DomainFields{}
	domainFields.Name = "cfapps.io"
	cfAppDomainFields := cf.DomainFields{}
	cfAppDomainFields.Name = "cf-app.com"
	org := cf.Organization{}
	org.Name = "my-org"
	org.Guid = "my-org-guid"
	org.QuotaDefinition = cf.NewQuotaFields("cantina-quota", 512)
	org.Spaces = []cf.SpaceFields{developmentSpaceFields, stagingSpaceFields}
	org.Domains = []cf.DomainFields{domainFields, cfAppDomainFields}

	reqFactory := &testreq.FakeReqFactory{Organization: org, LoginSuccess: true}

	args := []string{"my-org"}
	ui := callShowOrg(t, args, reqFactory)

	assert.Equal(t, reqFactory.OrganizationName, "my-org")

	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"Getting info for org", "my-org", "my-user"},
		{"OK"},
		{"my-org"},
		{"  domains:", "cfapps.io", "cf-app.com"},
		{"  quota: ", "cantina-quota", "512M"},
		{"  spaces:", "development", "staging"},
	})
}
開發者ID:nsnt,項目名稱:cli,代碼行數:32,代碼來源:show_org_test.go

示例5: TestTargetOrganizationAndSpace

func TestTargetOrganizationAndSpace(t *testing.T) {
	orgRepo, spaceRepo, configRepo, reqFactory := getTargetDependencies()
	configRepo.Delete()
	configRepo.Login()

	org := cf.Organization{}
	org.Name = "my-organization"
	org.Guid = "my-organization-guid"
	orgRepo.FindByNameOrganization = org

	space := cf.Space{}
	space.Name = "my-space"
	space.Guid = "my-space-guid"
	spaceRepo.FindByNameSpace = space

	ui := callTarget([]string{"-o", "my-organization", "-s", "my-space"}, reqFactory, configRepo, orgRepo, spaceRepo)

	savedConfig := testconfig.SavedConfiguration
	assert.True(t, ui.ShowConfigurationCalled)

	assert.Equal(t, orgRepo.FindByNameName, "my-organization")
	assert.Equal(t, savedConfig.OrganizationFields.Guid, "my-organization-guid")

	assert.Equal(t, spaceRepo.FindByNameName, "my-space")
	assert.Equal(t, savedConfig.SpaceFields.Guid, "my-space-guid")
}
開發者ID:nsnt,項目名稱:cli,代碼行數:26,代碼來源:target_test.go

示例6: TestSetSpaceRole

func TestSetSpaceRole(t *testing.T) {
	org := cf.Organization{}
	org.Guid = "my-org-guid"
	org.Name = "my-org"

	args := []string{"some-user", "some-org", "some-space", "SpaceManager"}

	reqFactory, spaceRepo, userRepo := getSetSpaceRoleDeps()
	reqFactory.LoginSuccess = true
	reqFactory.UserFields = cf.UserFields{}
	reqFactory.UserFields.Guid = "my-user-guid"
	reqFactory.UserFields.Username = "my-user"
	reqFactory.Organization = org

	spaceRepo.FindByNameInOrgSpace = cf.Space{}
	spaceRepo.FindByNameInOrgSpace.Guid = "my-space-guid"
	spaceRepo.FindByNameInOrgSpace.Name = "my-space"
	spaceRepo.FindByNameInOrgSpace.Organization = org.OrganizationFields

	ui := callSetSpaceRole(t, args, reqFactory, spaceRepo, userRepo)

	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"Assigning role ", "SpaceManager", "my-user", "my-org", "my-space", "current-user"},
		{"OK"},
	})

	assert.Equal(t, spaceRepo.FindByNameInOrgName, "some-space")
	assert.Equal(t, spaceRepo.FindByNameInOrgOrgGuid, "my-org-guid")

	assert.Equal(t, userRepo.SetSpaceRoleUserGuid, "my-user-guid")
	assert.Equal(t, userRepo.SetSpaceRoleSpaceGuid, "my-space-guid")
	assert.Equal(t, userRepo.SetSpaceRoleRole, cf.SPACE_MANAGER)
}
開發者ID:nsnt,項目名稱:cli,代碼行數:33,代碼來源:set_space_role_test.go

示例7: TestUnsetOrgRole

func TestUnsetOrgRole(t *testing.T) {
	userRepo := &testapi.FakeUserRepository{}
	user := cf.UserFields{}
	user.Username = "some-user"
	user.Guid = "some-user-guid"
	org := cf.Organization{}
	org.Name = "some-org"
	org.Guid = "some-org-guid"
	reqFactory := &testreq.FakeReqFactory{
		LoginSuccess: true,
		UserFields:   user,
		Organization: org,
	}
	args := []string{"my-username", "my-org", "OrgManager"}

	ui := callUnsetOrgRole(t, args, userRepo, reqFactory)

	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"Removing role", "OrgManager", "my-username", "my-org", "current-user"},
		{"OK"},
	})

	assert.Equal(t, userRepo.UnsetOrgRoleRole, cf.ORG_MANAGER)
	assert.Equal(t, userRepo.UnsetOrgRoleUserGuid, "some-user-guid")
	assert.Equal(t, userRepo.UnsetOrgRoleOrganizationGuid, "some-org-guid")
}
開發者ID:nsnt,項目名稱:cli,代碼行數:26,代碼來源:unset_org_role_test.go

示例8: TestLoggingInWithTooManyOrgsDoesNotShowOrgList

func TestLoggingInWithTooManyOrgsDoesNotShowOrgList(t *testing.T) {
	c := LoginTestContext{
		Inputs: []string{"api.example.com", "[email protected]", "password", "my-org-1", "my-space"},
	}

	callLogin(t, &c, func(c *LoginTestContext) {
		for i := 0; i < 60; i++ {
			id := strconv.Itoa(i)
			org := cf.Organization{}
			org.Guid = "my-org-guid-" + id
			org.Name = "my-org-" + id
			c.orgRepo.Organizations = append(c.orgRepo.Organizations, org)
		}

		c.orgRepo.FindByNameOrganization = c.orgRepo.Organizations[1]

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

		space2 := cf.Space{}
		space2.Guid = "some-space-guid"
		space2.Name = "some-space"

		c.spaceRepo.Spaces = []cf.Space{space1, space2}
	})

	savedConfig := testconfig.SavedConfiguration

	testassert.SliceDoesNotContain(t, c.ui.Outputs, testassert.Lines{
		{"my-org-2"},
	})
	assert.Equal(t, c.orgRepo.FindByNameName, "my-org-1")
	assert.Equal(t, savedConfig.OrganizationFields.Guid, "my-org-guid-1")
}
開發者ID:nsnt,項目名稱:cli,代碼行數:35,代碼來源:login_test.go

示例9: TestTargetOrganizationAndSpaceWhenSpaceFails

func TestTargetOrganizationAndSpaceWhenSpaceFails(t *testing.T) {
	orgRepo, spaceRepo, configRepo, reqFactory := getTargetDependencies()
	configRepo.Delete()
	configRepo.Login()

	org := cf.Organization{}
	org.Name = "my-organization"
	org.Guid = "my-organization-guid"
	orgRepo.FindByNameOrganization = org

	spaceRepo.FindByNameErr = true

	ui := callTarget([]string{"-o", "my-organization", "-s", "my-space"}, reqFactory, configRepo, orgRepo, spaceRepo)

	savedConfig := testconfig.SavedConfiguration
	assert.True(t, ui.ShowConfigurationCalled)

	assert.Equal(t, orgRepo.FindByNameName, "my-organization")
	assert.Equal(t, savedConfig.OrganizationFields.Guid, "my-organization-guid")
	assert.Equal(t, spaceRepo.FindByNameName, "my-space")
	assert.Equal(t, savedConfig.SpaceFields.Guid, "")
	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"FAILED"},
		{"Unable to access space", "my-space"},
	})
}
開發者ID:nsnt,項目名稱:cli,代碼行數:26,代碼來源:target_test.go

示例10: TestSuccessfullyLoggingInWithOnlyOneOrg

func TestSuccessfullyLoggingInWithOnlyOneOrg(t *testing.T) {
	org := cf.Organization{}
	org.Name = "my-org"
	org.Guid = "my-org-guid"

	c := LoginTestContext{
		Flags:  []string{"-s", "my-space"},
		Inputs: []string{"http://api.example.com", "[email protected]", "password"},
	}

	callLogin(t, &c, func(c *LoginTestContext) {
		c.orgRepo.FindByNameOrganization = cf.Organization{}
		c.orgRepo.Organizations = []cf.Organization{org}
	})

	savedConfig := testconfig.SavedConfiguration

	assert.Equal(t, savedConfig.Target, "http://api.example.com")
	assert.Equal(t, savedConfig.OrganizationFields.Guid, "my-org-guid")
	assert.Equal(t, savedConfig.SpaceFields.Guid, "my-space-guid")
	assert.Equal(t, savedConfig.AccessToken, "my_access_token")
	assert.Equal(t, savedConfig.RefreshToken, "my_refresh_token")

	assert.Equal(t, c.endpointRepo.UpdateEndpointReceived, "http://api.example.com")
	assert.Equal(t, c.authRepo.Email, "[email protected]")
	assert.Equal(t, c.authRepo.Password, "password")

	assert.True(t, c.ui.ShowConfigurationCalled)
}
開發者ID:nsnt,項目名稱:cli,代碼行數:29,代碼來源:login_test.go

示例11: TestDeleteUntargetedOrganizationDoesNotClearConfig

func TestDeleteUntargetedOrganizationDoesNotClearConfig(t *testing.T) {
	org := cf.Organization{}
	org.Name = "org-to-delete"
	org.Guid = "org-to-delete-guid"
	orgRepo := &testapi.FakeOrgRepository{FindByNameOrganization: org}

	configRepo := &testconfig.FakeConfigRepository{}
	config, _ := configRepo.Get()
	otherOrgFields := cf.OrganizationFields{}
	otherOrgFields.Guid = "some-other-org-guid"
	otherOrgFields.Name = "some-other-org"
	config.OrganizationFields = otherOrgFields

	spaceFields := cf.SpaceFields{}
	spaceFields.Name = "some-other-space"
	config.SpaceFields = spaceFields
	configRepo.Save()

	deleteOrg(t, "Yes", []string{"org-to-delete"}, orgRepo)

	updatedConfig, err := configRepo.Get()
	assert.NoError(t, err)

	assert.Equal(t, updatedConfig.OrganizationFields.Name, "some-other-org")
	assert.Equal(t, updatedConfig.SpaceFields.Name, "some-other-space")
}
開發者ID:nsnt,項目名稱:cli,代碼行數:26,代碼來源:delete_org_test.go

示例12: TestShowOrgFailsWithUsage

func TestShowOrgFailsWithUsage(t *testing.T) {
	org := cf.Organization{}
	org.Name = "my-org"
	org.Guid = "my-org-guid"
	reqFactory := &testreq.FakeReqFactory{Organization: org, LoginSuccess: true}

	args := []string{"my-org"}
	ui := callShowOrg(t, args, reqFactory)
	assert.False(t, ui.FailedWithUsage)

	args = []string{}
	ui = callShowOrg(t, args, reqFactory)
	assert.True(t, ui.FailedWithUsage)
}
開發者ID:nsnt,項目名稱:cli,代碼行數:14,代碼來源:show_org_test.go

示例13: TestOrgReqExecute

func TestOrgReqExecute(t *testing.T) {
	org := cf.Organization{}
	org.Name = "my-org"
	org.Guid = "my-org-guid"
	orgRepo := &testapi.FakeOrgRepository{FindByNameOrganization: org}
	ui := new(testterm.FakeUI)

	orgReq := newOrganizationRequirement("foo", ui, orgRepo)
	success := orgReq.Execute()

	assert.True(t, success)
	assert.Equal(t, orgRepo.FindByNameName, "foo")
	assert.Equal(t, orgReq.GetOrganization(), org)
}
開發者ID:nsnt,項目名稱:cli,代碼行數:14,代碼來源:organization_test.go

示例14: TestCreateDomain

func TestCreateDomain(t *testing.T) {
	org := cf.Organization{}
	org.Name = "myOrg"
	org.Guid = "myOrg-guid"
	reqFactory := &testreq.FakeReqFactory{LoginSuccess: true, Organization: org}
	domainRepo := &testapi.FakeDomainRepository{}
	ui := callCreateDomain(t, []string{"myOrg", "example.com"}, reqFactory, domainRepo)

	assert.Equal(t, domainRepo.CreateDomainName, "example.com")
	assert.Equal(t, domainRepo.CreateDomainOwningOrgGuid, "myOrg-guid")
	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"Creating domain", "example.com", "myOrg", "my-user"},
		{"OK"},
	})
}
開發者ID:nsnt,項目名稱:cli,代碼行數:15,代碼來源:create_domain_test.go

示例15: TestDeleteOrgWithForceOption

func TestDeleteOrgWithForceOption(t *testing.T) {
	org := cf.Organization{}
	org.Name = "org-to-delete"
	org.Guid = "org-to-delete-guid"
	orgRepo := &testapi.FakeOrgRepository{FindByNameOrganization: org}

	ui := deleteOrg(t, "Yes", []string{"-f", "org-to-delete"}, orgRepo)

	assert.Equal(t, len(ui.Prompts), 0)
	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"Deleting", "org-to-delete"},
		{"OK"},
	})
	assert.Equal(t, orgRepo.FindByNameName, "org-to-delete")
	assert.Equal(t, orgRepo.DeletedOrganizationGuid, "org-to-delete-guid")
}
開發者ID:nsnt,項目名稱:cli,代碼行數:16,代碼來源:delete_org_test.go


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