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


Golang UserFields.Guid方法代碼示例

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


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

示例1: deleteWithConfirmation

func deleteWithConfirmation(t *testing.T, confirmation string) (ui *testterm.FakeUI, userRepo *testapi.FakeUserRepository) {
	ui = &testterm.FakeUI{
		Inputs: []string{confirmation},
	}
	user2 := cf.UserFields{}
	user2.Username = "my-found-user"
	user2.Guid = "my-found-user-guid"
	userRepo = &testapi.FakeUserRepository{
		FindByUsernameUserFields: user2,
	}

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

	cmd := NewDeleteUser(ui, config, userRepo)

	ctxt := testcmd.NewContext("delete-user", []string{"my-user"})
	reqFactory := &testreq.FakeReqFactory{LoginSuccess: true}

	testcmd.RunCommand(cmd, ctxt, reqFactory)
	return
}
開發者ID:nsnt,項目名稱:cli,代碼行數:33,代碼來源:delete_user_test.go

示例2: TestUnsetSpaceRole

func TestUnsetSpaceRole(t *testing.T) {
	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, spaceRepo, userRepo := getUnsetSpaceRoleDeps()
	reqFactory.LoginSuccess = true
	reqFactory.UserFields = user
	reqFactory.Organization = org
	spaceRepo.FindByNameInOrgSpace = cf.Space{}
	spaceRepo.FindByNameInOrgSpace.Name = "some-space"
	spaceRepo.FindByNameInOrgSpace.Guid = "some-space-guid"

	args := []string{"my-username", "my-org", "my-space", "SpaceManager"}

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

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

	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"Removing role", "SpaceManager", "some-user", "some-org", "some-space", "current-user"},
		{"OK"},
	})
	assert.Equal(t, userRepo.UnsetSpaceRoleRole, cf.SPACE_MANAGER)
	assert.Equal(t, userRepo.UnsetSpaceRoleUserGuid, "some-user-guid")
	assert.Equal(t, userRepo.UnsetSpaceRoleSpaceGuid, "some-space-guid")
}
開發者ID:nsnt,項目名稱:cli,代碼行數:31,代碼來源:unset_space_role_test.go

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

示例4: TestUserReqExecute

func TestUserReqExecute(t *testing.T) {
	user := cf.UserFields{}
	user.Username = "my-user"
	user.Guid = "my-user-guid"

	userRepo := &testapi.FakeUserRepository{FindByUsernameUserFields: user}
	ui := new(testterm.FakeUI)

	userReq := newUserRequirement("foo", ui, userRepo)
	success := userReq.Execute()

	assert.True(t, success)
	assert.Equal(t, userRepo.FindByUsernameUsername, "foo")
	assert.Equal(t, userReq.GetUser(), user)
}
開發者ID:nsnt,項目名稱:cli,代碼行數:15,代碼來源:user_test.go

示例5: TestDeleteUserWithForceOption

func TestDeleteUserWithForceOption(t *testing.T) {
	foundUserFields := cf.UserFields{}
	foundUserFields.Guid = "my-found-user-guid"
	userRepo := &testapi.FakeUserRepository{FindByUsernameUserFields: foundUserFields}
	reqFactory := &testreq.FakeReqFactory{LoginSuccess: true}

	ui := callDeleteUser(t, []string{"-f", "my-user"}, userRepo, reqFactory)

	assert.Equal(t, len(ui.Outputs), 2)
	assert.Equal(t, len(ui.Prompts), 0)
	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"Deleting user", "my-user"},
		{"OK"},
	})

	assert.Equal(t, userRepo.FindByUsernameUsername, "my-user")
	assert.Equal(t, userRepo.DeleteUserGuid, "my-found-user-guid")
}
開發者ID:nsnt,項目名稱:cli,代碼行數:18,代碼來源:delete_user_test.go

示例6: TestFindByUsername

func TestFindByUsername(t *testing.T) {
	usersResponse := `{ "resources": [
        { "id": "my-guid", "userName": "my-full-username" }
    ]}`

	uaaReq := testapi.NewCloudControllerTestRequest(testnet.TestRequest{
		Method:   "GET",
		Path:     "/Users?attributes=id,userName&filter=userName+Eq+%22damien%2Buser1%40pivotallabs.com%22",
		Response: testnet.TestResponse{Status: http.StatusOK, Body: usersResponse},
	})

	uaa, handler, repo := createUsersRepoWithoutCCEndpoints(t, []testnet.TestRequest{uaaReq})
	defer uaa.Close()

	user, apiResponse := repo.FindByUsername("[email protected]")
	assert.True(t, handler.AllRequestsCalled())
	assert.True(t, apiResponse.IsSuccessful())

	expectedUserFields := cf.UserFields{}
	expectedUserFields.Username = "my-full-username"
	expectedUserFields.Guid = "my-guid"
	assert.Equal(t, user, expectedUserFields)
}
開發者ID:nsnt,項目名稱:cli,代碼行數:23,代碼來源:users_test.go


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