本文整理匯總了Golang中github.com/cloudfoundry/cli/cf/api/fakes.FakeUserRepository類的典型用法代碼示例。如果您正苦於以下問題:Golang FakeUserRepository類的具體用法?Golang FakeUserRepository怎麽用?Golang FakeUserRepository使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了FakeUserRepository類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1:
testterm "github.com/cloudfoundry/cli/testhelpers/terminal"
. "github.com/cloudfoundry/cli/testhelpers/matchers"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("UnsetOrgRole", func() {
var (
ui *testterm.FakeUI
configRepo core_config.Repository
userRepo *testapi.FakeUserRepository
flagRepo *fakefeatureflagsapi.FakeFeatureFlagRepository
cmd command_registry.Command
deps command_registry.Dependency
factory *fakerequirements.FakeFactory
flagContext flags.FlagContext
loginRequirement requirements.Requirement
userRequirement *fakerequirements.FakeUserRequirement
organizationRequirement *fakerequirements.FakeOrganizationRequirement
)
BeforeEach(func() {
ui = &testterm.FakeUI{}
configRepo = testconfig.NewRepositoryWithDefaults()
userRepo = &testapi.FakeUserRepository{}
repoLocator := deps.RepoLocator.SetUserRepository(userRepo)
flagRepo = &fakefeatureflagsapi.FakeFeatureFlagRepository{}
repoLocator = repoLocator.SetFeatureFlagRepository(flagRepo)
示例2:
testcmd "github.com/cloudfoundry/cli/testhelpers/commands"
testconfig "github.com/cloudfoundry/cli/testhelpers/configuration"
testreq "github.com/cloudfoundry/cli/testhelpers/requirements"
testterm "github.com/cloudfoundry/cli/testhelpers/terminal"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/cloudfoundry/cli/testhelpers/matchers"
)
var _ = Describe("unset-space-role command", func() {
var (
ui *testterm.FakeUI
configRepo core_config.Repository
requirementsFactory *testreq.FakeReqFactory
userRepo *testapi.FakeUserRepository
spaceRepo *testapi.FakeSpaceRepository
deps command_registry.Dependency
)
updateCommandDependency := func(pluginCall bool) {
deps.Ui = ui
deps.Config = configRepo
deps.RepoLocator = deps.RepoLocator.SetUserRepository(userRepo)
deps.RepoLocator = deps.RepoLocator.SetSpaceRepository(spaceRepo)
command_registry.Commands.SetCommand(command_registry.Commands.FindCommand("unset-space-role").SetDependency(deps, pluginCall))
}
callUnsetSpaceRole := func(args []string, spaceRepo *testapi.FakeSpaceRepository, userRepo *testapi.FakeUserRepository, requirementsFactory *testreq.FakeReqFactory) (*testterm.FakeUI, bool) {
ui = &testterm.FakeUI{}
configRepo = testconfig.NewRepositoryWithDefaults()
示例3:
"github.com/cloudfoundry/cli/plugin/models"
testcmd "github.com/cloudfoundry/cli/testhelpers/commands"
testconfig "github.com/cloudfoundry/cli/testhelpers/configuration"
testreq "github.com/cloudfoundry/cli/testhelpers/requirements"
testterm "github.com/cloudfoundry/cli/testhelpers/terminal"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/cloudfoundry/cli/testhelpers/matchers"
)
var _ = Describe("space-users command", func() {
var (
ui *testterm.FakeUI
requirementsFactory *testreq.FakeReqFactory
spaceRepo *testapi.FakeSpaceRepository
userRepo *testapi.FakeUserRepository
configRepo core_config.Repository
deps command_registry.Dependency
)
updateCommandDependency := func(pluginCall bool) {
deps.Ui = ui
deps.Config = configRepo
deps.RepoLocator = deps.RepoLocator.SetUserRepository(userRepo)
deps.RepoLocator = deps.RepoLocator.SetSpaceRepository(spaceRepo)
command_registry.Commands.SetCommand(command_registry.Commands.FindCommand("space-users").SetDependency(deps, pluginCall))
}
BeforeEach(func() {
configRepo = testconfig.NewRepositoryWithDefaults()
示例4:
"github.com/cloudfoundry/cli/cf/models"
testcmd "github.com/cloudfoundry/cli/testhelpers/commands"
testconfig "github.com/cloudfoundry/cli/testhelpers/configuration"
testreq "github.com/cloudfoundry/cli/testhelpers/requirements"
testterm "github.com/cloudfoundry/cli/testhelpers/terminal"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/cloudfoundry/cli/testhelpers/matchers"
)
var _ = Describe("space-users command", func() {
var (
ui *testterm.FakeUI
requirementsFactory *testreq.FakeReqFactory
spaceRepo *testapi.FakeSpaceRepository
userRepo *testapi.FakeUserRepository
config configuration.ReadWriter
)
BeforeEach(func() {
config = testconfig.NewRepositoryWithDefaults()
ui = &testterm.FakeUI{}
requirementsFactory = &testreq.FakeReqFactory{}
spaceRepo = &testapi.FakeSpaceRepository{}
userRepo = &testapi.FakeUserRepository{}
})
runCommand := func(args ...string) {
testcmd.RunCommand(NewSpaceUsers(ui, config, spaceRepo, userRepo), args, requirementsFactory)
}
示例5:
testapi "github.com/cloudfoundry/cli/cf/api/fakes"
testconfig "github.com/cloudfoundry/cli/testhelpers/configuration"
testreq "github.com/cloudfoundry/cli/testhelpers/requirements"
testterm "github.com/cloudfoundry/cli/testhelpers/terminal"
. "github.com/cloudfoundry/cli/testhelpers/matchers"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("SetSpaceRole", func() {
var (
ui *testterm.FakeUI
configRepo core_config.Repository
userRepo *testapi.FakeUserRepository
spaceRepo *testapi.FakeSpaceRepository
cmd command_registry.Command
requirementsFactory *testreq.FakeReqFactory
flagContext flags.FlagContext
)
BeforeEach(func() {
ui = &testterm.FakeUI{}
configRepo = testconfig.NewRepositoryWithDefaults()
userRepo = &testapi.FakeUserRepository{}
spaceRepo = &testapi.FakeSpaceRepository{}
deps := command_registry.Dependency{}
repoLocator := deps.RepoLocator
repoLocator = repoLocator.SetUserRepository(userRepo)
repoLocator = repoLocator.SetSpaceRepository(spaceRepo)
示例6:
"errors"
"github.com/cloudfoundry/cli/cf/models"
"github.com/cloudfoundry/cli/cf/requirements"
fakeapi "github.com/cloudfoundry/cli/cf/api/fakes"
testterm "github.com/cloudfoundry/cli/testhelpers/terminal"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("UserRequirement", func() {
var (
ui *testterm.FakeUI
userRepo *fakeapi.FakeUserRepository
userRequirement requirements.UserRequirement
)
BeforeEach(func() {
ui = new(testterm.FakeUI)
userRepo = &fakeapi.FakeUserRepository{}
})
Describe("Execute", func() {
Context("when wantGuid is true", func() {
BeforeEach(func() {
userRequirement = requirements.NewUserRequirement("the-username", ui, userRepo, true)
})
It("tries to find the user in CC", func() {
示例7:
. "github.com/cloudfoundry/cli/cf/commands/user"
"github.com/cloudfoundry/cli/cf/configuration/core_config"
testcmd "github.com/cloudfoundry/cli/testhelpers/commands"
testconfig "github.com/cloudfoundry/cli/testhelpers/configuration"
testreq "github.com/cloudfoundry/cli/testhelpers/requirements"
testterm "github.com/cloudfoundry/cli/testhelpers/terminal"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/cloudfoundry/cli/testhelpers/matchers"
)
var _ = Describe("Create user command", func() {
var (
requirementsFactory *testreq.FakeReqFactory
ui *testterm.FakeUI
userRepo *testapi.FakeUserRepository
configRepo core_config.ReadWriter
)
BeforeEach(func() {
requirementsFactory = &testreq.FakeReqFactory{LoginSuccess: true}
ui = new(testterm.FakeUI)
userRepo = &testapi.FakeUserRepository{}
configRepo = testconfig.NewRepositoryWithDefaults()
accessToken, _ := testconfig.EncodeAccessToken(core_config.TokenInfo{
Username: "current-user",
})
configRepo.SetAccessToken(accessToken)
})
runCommand := func(args ...string) bool {
示例8:
testterm "github.com/cloudfoundry/cli/testhelpers/terminal"
. "github.com/cloudfoundry/cli/testhelpers/matchers"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("create-space command", func() {
var (
ui *testterm.FakeUI
requirementsFactory *testreq.FakeReqFactory
configSpace models.SpaceFields
configOrg models.OrganizationFields
configRepo core_config.Repository
spaceRepo *testapi.FakeSpaceRepository
orgRepo *fake_org.FakeOrganizationRepository
userRepo *testapi.FakeUserRepository
spaceRoleSetter user.SpaceRoleSetter
flagRepo *fakeflag.FakeFeatureFlagRepository
spaceQuotaRepo *fakes.FakeSpaceQuotaRepository
OriginalCommand command_registry.Command
deps command_registry.Dependency
)
updateCommandDependency := func(pluginCall bool) {
deps.Ui = ui
deps.RepoLocator = deps.RepoLocator.SetSpaceRepository(spaceRepo)
deps.RepoLocator = deps.RepoLocator.SetSpaceQuotaRepository(spaceQuotaRepo)
deps.RepoLocator = deps.RepoLocator.SetOrganizationRepository(orgRepo)
deps.RepoLocator = deps.RepoLocator.SetFeatureFlagRepository(flagRepo)
deps.RepoLocator = deps.RepoLocator.SetUserRepository(userRepo)
示例9:
. "github.com/cloudfoundry/cli/cf/commands/user"
"github.com/cloudfoundry/cli/cf/configuration"
testcmd "github.com/cloudfoundry/cli/testhelpers/commands"
testconfig "github.com/cloudfoundry/cli/testhelpers/configuration"
testreq "github.com/cloudfoundry/cli/testhelpers/requirements"
testterm "github.com/cloudfoundry/cli/testhelpers/terminal"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/cloudfoundry/cli/testhelpers/matchers"
)
var _ = Describe("Create user command", func() {
var (
requirementsFactory *testreq.FakeReqFactory
ui *testterm.FakeUI
userRepo *testapi.FakeUserRepository
configRepo configuration.ReadWriter
)
BeforeEach(func() {
requirementsFactory = &testreq.FakeReqFactory{LoginSuccess: true}
ui = new(testterm.FakeUI)
userRepo = &testapi.FakeUserRepository{}
configRepo = testconfig.NewRepositoryWithDefaults()
accessToken, _ := testconfig.EncodeAccessToken(configuration.TokenInfo{
Username: "current-user",
})
configRepo.SetAccessToken(accessToken)
})
runCommand := func(args ...string) {
示例10:
testcmd "github.com/cloudfoundry/cli/testhelpers/commands"
testconfig "github.com/cloudfoundry/cli/testhelpers/configuration"
testreq "github.com/cloudfoundry/cli/testhelpers/requirements"
testterm "github.com/cloudfoundry/cli/testhelpers/terminal"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/cloudfoundry/cli/testhelpers/matchers"
)
var _ = Describe("set-space-role command", func() {
var (
ui *testterm.FakeUI
requirementsFactory *testreq.FakeReqFactory
spaceRepo *testapi.FakeSpaceRepository
userRepo *testapi.FakeUserRepository
configRepo core_config.Repository
flagRepo *fakeflag.FakeFeatureFlagRepository
deps command_registry.Dependency
)
updateCommandDependency := func(pluginCall bool) {
deps.Ui = ui
deps.RepoLocator = deps.RepoLocator.SetSpaceRepository(spaceRepo)
deps.RepoLocator = deps.RepoLocator.SetUserRepository(userRepo)
deps.RepoLocator = deps.RepoLocator.SetFeatureFlagRepository(flagRepo)
deps.Config = configRepo
command_registry.Commands.SetCommand(command_registry.Commands.FindCommand("set-space-role").SetDependency(deps, pluginCall))
}
BeforeEach(func() {
示例11:
"github.com/cloudfoundry/cli/cf/models"
testcmd "github.com/cloudfoundry/cli/testhelpers/commands"
testconfig "github.com/cloudfoundry/cli/testhelpers/configuration"
testreq "github.com/cloudfoundry/cli/testhelpers/requirements"
testterm "github.com/cloudfoundry/cli/testhelpers/terminal"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/cloudfoundry/cli/testhelpers/matchers"
)
var _ = Describe("unset-org-role command", func() {
var (
ui *testterm.FakeUI
userRepo *testapi.FakeUserRepository
configRepo core_config.Repository
requirementsFactory *testreq.FakeReqFactory
deps command_registry.Dependency
)
updateCommandDependency := func(pluginCall bool) {
deps.Ui = ui
deps.Config = configRepo
deps.RepoLocator = deps.RepoLocator.SetUserRepository(userRepo)
command_registry.Commands.SetCommand(command_registry.Commands.FindCommand("unset-org-role").SetDependency(deps, pluginCall))
}
runCommand := func(args ...string) bool {
return testcmd.RunCliCommand("unset-org-role", args, requirementsFactory, updateCommandDependency, false)
}
示例12:
testcmd "github.com/cloudfoundry/cli/testhelpers/commands"
testconfig "github.com/cloudfoundry/cli/testhelpers/configuration"
testreq "github.com/cloudfoundry/cli/testhelpers/requirements"
testterm "github.com/cloudfoundry/cli/testhelpers/terminal"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/cloudfoundry/cli/cf/command_registry"
. "github.com/cloudfoundry/cli/testhelpers/matchers"
)
var _ = Describe("Create user command", func() {
var (
requirementsFactory *testreq.FakeReqFactory
ui *testterm.FakeUI
userRepo *testapi.FakeUserRepository
config core_config.Repository
deps command_registry.Dependency
)
BeforeEach(func() {
requirementsFactory = &testreq.FakeReqFactory{LoginSuccess: true}
ui = new(testterm.FakeUI)
userRepo = &testapi.FakeUserRepository{}
config = testconfig.NewRepositoryWithDefaults()
accessToken, _ := testconfig.EncodeAccessToken(core_config.TokenInfo{
Username: "current-user",
})
config.SetAccessToken(accessToken)
})
示例13:
"github.com/cloudfoundry/cli/cf/models"
testcmd "github.com/cloudfoundry/cli/testhelpers/commands"
testconfig "github.com/cloudfoundry/cli/testhelpers/configuration"
testreq "github.com/cloudfoundry/cli/testhelpers/requirements"
testterm "github.com/cloudfoundry/cli/testhelpers/terminal"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/cloudfoundry/cli/testhelpers/matchers"
)
var _ = Describe("delete-user command", func() {
var (
ui *testterm.FakeUI
configRepo core_config.Repository
userRepo *testapi.FakeUserRepository
requirementsFactory *testreq.FakeReqFactory
deps command_registry.Dependency
)
updateCommandDependency := func(pluginCall bool) {
deps.Ui = ui
deps.Config = configRepo
deps.RepoLocator = deps.RepoLocator.SetUserRepository(userRepo)
command_registry.Commands.SetCommand(command_registry.Commands.FindCommand("delete-user").SetDependency(deps, pluginCall))
}
BeforeEach(func() {
ui = &testterm.FakeUI{Inputs: []string{"y"}}
userRepo = &testapi.FakeUserRepository{}
requirementsFactory = &testreq.FakeReqFactory{LoginSuccess: true}
示例14:
"github.com/cloudfoundry/cli/cf/configuration"
"github.com/cloudfoundry/cli/cf/models"
testcmd "github.com/cloudfoundry/cli/testhelpers/commands"
testconfig "github.com/cloudfoundry/cli/testhelpers/configuration"
testreq "github.com/cloudfoundry/cli/testhelpers/requirements"
testterm "github.com/cloudfoundry/cli/testhelpers/terminal"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/cloudfoundry/cli/testhelpers/matchers"
)
var _ = Describe("delete-user command", func() {
var (
ui *testterm.FakeUI
configRepo configuration.ReadWriter
userRepo *testapi.FakeUserRepository
requirementsFactory *testreq.FakeReqFactory
)
BeforeEach(func() {
ui = &testterm.FakeUI{Inputs: []string{"y"}}
userRepo = &testapi.FakeUserRepository{}
requirementsFactory = &testreq.FakeReqFactory{LoginSuccess: true}
configRepo = testconfig.NewRepositoryWithDefaults()
token, err := testconfig.EncodeAccessToken(configuration.TokenInfo{
UserGuid: "admin-user-guid",
Username: "admin-user",
})
Expect(err).ToNot(HaveOccurred())
configRepo.SetAccessToken(token)
示例15:
"github.com/cloudfoundry/cli/plugin/models"
testcmd "github.com/cloudfoundry/cli/testhelpers/commands"
testconfig "github.com/cloudfoundry/cli/testhelpers/configuration"
testreq "github.com/cloudfoundry/cli/testhelpers/requirements"
testterm "github.com/cloudfoundry/cli/testhelpers/terminal"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/cloudfoundry/cli/testhelpers/matchers"
)
var _ = Describe("org-users command", func() {
var (
ui *testterm.FakeUI
requirementsFactory *testreq.FakeReqFactory
configRepo core_config.Repository
userRepo *testapi.FakeUserRepository
deps command_registry.Dependency
)
updateCommandDependency := func(pluginCall bool) {
deps.Ui = ui
deps.Config = configRepo
deps.RepoLocator = deps.RepoLocator.SetUserRepository(userRepo)
command_registry.Commands.SetCommand(command_registry.Commands.FindCommand("org-users").SetDependency(deps, pluginCall))
}
BeforeEach(func() {
ui = &testterm.FakeUI{}
userRepo = &testapi.FakeUserRepository{}