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


Golang Space.Guid方法代碼示例

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


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

示例1: 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

示例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: TestSuccessfullyLoggingInWithOnlyOneSpace

func TestSuccessfullyLoggingInWithOnlyOneSpace(t *testing.T) {
	space := cf.Space{}
	space.Guid = "my-space-guid"
	space.Name = "my-space"

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

	callLogin(t, &c, func(c *LoginTestContext) {
		c.spaceRepo.Spaces = []cf.Space{space}
	})

	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,代碼行數:28,代碼來源:login_test.go

示例4: 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

示例5: TestSpaceReqExecute

func TestSpaceReqExecute(t *testing.T) {
	space := cf.Space{}
	space.Name = "my-space"
	space.Guid = "my-space-guid"
	spaceRepo := &testapi.FakeSpaceRepository{FindByNameSpace: space}
	ui := new(testterm.FakeUI)

	spaceReq := newSpaceRequirement("foo", ui, spaceRepo)
	success := spaceReq.Execute()

	assert.True(t, success)
	assert.Equal(t, spaceRepo.FindByNameName, "foo")
	assert.Equal(t, spaceReq.GetSpace(), space)
}
開發者ID:nsnt,項目名稱:cli,代碼行數:14,代碼來源:space_test.go

示例6: TestRenameSpaceRun

func TestRenameSpaceRun(t *testing.T) {
	spaceRepo := &testapi.FakeSpaceRepository{}
	space := cf.Space{}
	space.Name = "my-space"
	space.Guid = "my-space-guid"
	reqFactory := &testreq.FakeReqFactory{LoginSuccess: true, TargetedOrgSuccess: true, Space: space}
	ui := callRenameSpace(t, []string{"my-space", "my-new-space"}, reqFactory, spaceRepo)

	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"Renaming space", "my-space", "my-new-space", "my-org", "my-user"},
		{"OK"},
	})

	assert.Equal(t, spaceRepo.RenameSpaceGuid, "my-space-guid")
	assert.Equal(t, spaceRepo.RenameNewName, "my-new-space")
}
開發者ID:nsnt,項目名稱:cli,代碼行數:16,代碼來源:rename_space_test.go

示例7: TestSpaceUsers

func TestSpaceUsers(t *testing.T) {
	org := cf.Organization{}
	org.Name = "Org1"
	org.Guid = "org1-guid"
	space := cf.Space{}
	space.Name = "Space1"
	space.Guid = "space1-guid"

	reqFactory := &testreq.FakeReqFactory{LoginSuccess: true, Organization: org}
	spaceRepo := &testapi.FakeSpaceRepository{FindByNameInOrgSpace: space}
	userRepo := &testapi.FakeUserRepository{}

	user := cf.UserFields{}
	user.Username = "user1"
	user2 := cf.UserFields{}
	user2.Username = "user2"
	user3 := cf.UserFields{}
	user3.Username = "user3"
	user4 := cf.UserFields{}
	user4.Username = "user4"
	userRepo.ListUsersByRole = map[string][]cf.UserFields{
		cf.SPACE_MANAGER:   []cf.UserFields{user, user2},
		cf.SPACE_DEVELOPER: []cf.UserFields{user4},
		cf.SPACE_AUDITOR:   []cf.UserFields{user3},
	}

	ui := callSpaceUsers(t, []string{"my-org", "my-space"}, reqFactory, spaceRepo, userRepo)

	assert.Equal(t, spaceRepo.FindByNameInOrgName, "my-space")
	assert.Equal(t, spaceRepo.FindByNameInOrgOrgGuid, "org1-guid")
	assert.Equal(t, userRepo.ListUsersSpaceGuid, "space1-guid")

	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"Getting users in org", "Org1", "Space1", "my-user"},
		{"SPACE MANAGER"},
		{"user1"},
		{"user2"},
		{"SPACE DEVELOPER"},
		{"user4"},
		{"SPACE AUDITOR"},
		{"user3"},
	})
}
開發者ID:nsnt,項目名稱:cli,代碼行數:43,代碼來源:space_users_test.go

示例8: callLogin

func callLogin(t *testing.T, c *LoginTestContext, beforeBlock func(*LoginTestContext)) {

	c.configRepo = testconfig.FakeConfigRepository{}
	c.ui = &testterm.FakeUI{
		Inputs: c.Inputs,
	}
	c.authRepo = &testapi.FakeAuthenticationRepository{
		AccessToken:  "my_access_token",
		RefreshToken: "my_refresh_token",
		ConfigRepo:   c.configRepo,
	}
	c.endpointRepo = &testapi.FakeEndpointRepo{}

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

	c.orgRepo = &testapi.FakeOrgRepository{
		FindByNameOrganization: org,
	}

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

	c.spaceRepo = &testapi.FakeSpaceRepository{
		FindByNameSpace: space,
	}

	c.configRepo.Delete()
	config, _ := c.configRepo.Get()
	config.Target = c.Config.Target
	config.OrganizationFields = c.Config.OrganizationFields
	config.SpaceFields = c.Config.SpaceFields

	beforeBlock(c)

	l := NewLogin(c.ui, c.configRepo, c.authRepo, c.endpointRepo, c.orgRepo, c.spaceRepo)
	l.Run(testcmd.NewContext("login", c.Flags))
}
開發者ID:nsnt,項目名稱:cli,代碼行數:40,代碼來源:login_test.go

示例9: TestTargetSpaceWhenUserHasAccess

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

	configRepo.Delete()
	config := configRepo.Login()
	config.OrganizationFields = cf.OrganizationFields{}
	config.OrganizationFields.Name = "my-org"
	config.OrganizationFields.Guid = "my-org-guid"

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

	spaceRepo.Spaces = []cf.Space{space}
	spaceRepo.FindByNameSpace = space

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

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

示例10: getDomainMapperDeps

func getDomainMapperDeps() (reqFactory *testreq.FakeReqFactory, domainRepo *testapi.FakeDomainRepository) {
	domain := cf.Domain{}
	domain.Name = "foo.com"
	domain.Guid = "foo-guid"
	domainRepo = &testapi.FakeDomainRepository{
		FindByNameInOrgDomain: domain,
	}

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

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

	reqFactory = &testreq.FakeReqFactory{
		LoginSuccess:       true,
		TargetedOrgSuccess: true,
		Organization:       org,
		Space:              space,
	}
	return
}
開發者ID:pmuellr,項目名稱:cli,代碼行數:24,代碼來源:domain_mapper_test.go

示例11: defaultDeleteSpaceSpace

func defaultDeleteSpaceSpace() cf.Space {
	space := cf.Space{}
	space.Name = "space-to-delete"
	space.Guid = "space-to-delete-guid"
	return space
}
開發者ID:nsnt,項目名稱:cli,代碼行數:6,代碼來源:delete_space_test.go


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