本文整理汇总了Golang中github.com/cloudfoundry/cli/testhelpers/configuration.NewRepositoryWithAccessToken函数的典型用法代码示例。如果您正苦于以下问题:Golang NewRepositoryWithAccessToken函数的具体用法?Golang NewRepositoryWithAccessToken怎么用?Golang NewRepositoryWithAccessToken使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewRepositoryWithAccessToken函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: callShareDomain
func callShareDomain(args []string, requirementsFactory *testreq.FakeReqFactory, domainRepo *testapi.FakeDomainRepository) (fakeUI *testterm.FakeUI) {
fakeUI = new(testterm.FakeUI)
configRepo := testconfig.NewRepositoryWithAccessToken(configuration.TokenInfo{Username: "my-user"})
cmd := NewCreateSharedDomain(fakeUI, configRepo, domainRepo)
testcmd.RunCommand(cmd, args, requirementsFactory)
return
}
示例2: callShowOrg
func callShowOrg(args []string, requirementsFactory *testreq.FakeReqFactory) (ui *testterm.FakeUI) {
ui = new(testterm.FakeUI)
token := core_config.TokenInfo{Username: "my-user"}
spaceFields := models.SpaceFields{}
spaceFields.Name = "my-space"
orgFields := models.OrganizationFields{}
orgFields.Name = "my-org"
configRepo := testconfig.NewRepositoryWithAccessToken(token)
configRepo.SetSpaceFields(spaceFields)
configRepo.SetOrganizationFields(orgFields)
return
}
示例3: callListDomains
func callListDomains(args []string, requirementsFactory *testreq.FakeReqFactory, domainRepo *testapi.FakeDomainRepository) (fakeUI *testterm.FakeUI) {
fakeUI = new(testterm.FakeUI)
configRepo := testconfig.NewRepositoryWithAccessToken(configuration.TokenInfo{Username: "my-user"})
spaceFields := models.SpaceFields{}
spaceFields.Name = "my-space"
orgFields := models.OrganizationFields{}
orgFields.Name = "my-org"
configRepo.SetSpaceFields(spaceFields)
configRepo.SetOrganizationFields(orgFields)
cmd := domain.NewListDomains(fakeUI, configRepo, domainRepo)
testcmd.RunCommand(cmd, args, requirementsFactory)
return
}
示例4: callDeleteSharedDomain
func callDeleteSharedDomain(args []string, inputs []string, deps deleteSharedDomainDependencies) (ui *testterm.FakeUI) {
ui = &testterm.FakeUI{
Inputs: inputs,
}
configRepo := testconfig.NewRepositoryWithAccessToken(configuration.TokenInfo{Username: "my-user"})
spaceFields := models.SpaceFields{}
spaceFields.Name = "my-space"
orgFields := models.OrganizationFields{}
orgFields.Name = "my-org"
configRepo.SetSpaceFields(spaceFields)
configRepo.SetOrganizationFields(orgFields)
cmd := domain.NewDeleteSharedDomain(ui, configRepo, deps.domainRepo)
testcmd.RunCommand(cmd, args, deps.requirementsFactory)
return
}
示例5: callCreateOrg
func callCreateOrg(args []string, requirementsFactory *testreq.FakeReqFactory, orgRepo *testapi.FakeOrgRepository) (fakeUI *testterm.FakeUI) {
fakeUI = new(testterm.FakeUI)
space := models.SpaceFields{}
space.Name = "my-space"
organization := models.OrganizationFields{}
organization.Name = "my-org"
token := configuration.TokenInfo{Username: "my-user"}
config := testconfig.NewRepositoryWithAccessToken(token)
config.SetSpaceFields(space)
config.SetOrganizationFields(organization)
cmd := NewCreateOrg(fakeUI, config, orgRepo)
testcmd.RunCommand(cmd, args, requirementsFactory)
return
}
示例6:
import (
"github.com/cloudfoundry/cli/cf/configuration/coreconfig"
. "github.com/cloudfoundry/cli/cf/requirements"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
testconfig "github.com/cloudfoundry/cli/testhelpers/configuration"
)
var _ = Describe("LoginRequirement", func() {
BeforeEach(func() {
})
It("succeeds when given a config with an API endpoint and authentication", func() {
config := testconfig.NewRepositoryWithAccessToken(coreconfig.TokenInfo{Username: "my-user"})
config.SetAPIEndpoint("api.example.com")
req := NewLoginRequirement(config)
err := req.Execute()
Expect(err).NotTo(HaveOccurred())
})
It("fails when given a config with only an API endpoint", func() {
config := testconfig.NewRepository()
config.SetAPIEndpoint("api.example.com")
req := NewLoginRequirement(config)
err := req.Execute()
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("Not logged in."))
})
示例7:
Expect(output).ToNot(ContainSubstrings([]string{"API endpoint:"}))
Expect(output).To(ContainSubstrings([]string{"Not logged in", "Use", "log in"}))
})
})
Context("when an api endpoint is set and the user logged in", func() {
var config coreconfig.ReadWriter
BeforeEach(func() {
accessToken := coreconfig.TokenInfo{
UserGUID: "my-user-guid",
Username: "my-user",
Email: "my-user-email",
}
config = testconfig.NewRepositoryWithAccessToken(accessToken)
config.SetAPIEndpoint("https://test.example.org")
config.SetAPIVersion("☃☃☃")
})
Describe("tells the user what is set in the config", func() {
var output []string
JustBeforeEach(func() {
output = io_helpers.CaptureOutput(func() {
ui := NewUI(os.Stdin, os.Stdout, NewTeePrinter(os.Stdout), fakeLogger)
ui.ShowConfiguration(config)
})
})
It("tells the user which api endpoint is set", func() {
示例8:
. "github.com/cloudfoundry/cli/testhelpers/matchers"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Testing with ginkgo", func() {
var (
requirementsFactory *testreq.FakeReqFactory
ui *testterm.FakeUI
domainRepo *testapi.FakeDomainRepository
configRepo configuration.ReadWriter
)
BeforeEach(func() {
requirementsFactory = &testreq.FakeReqFactory{LoginSuccess: true}
domainRepo = &testapi.FakeDomainRepository{}
configRepo = testconfig.NewRepositoryWithAccessToken(configuration.TokenInfo{Username: "my-user"})
})
runCommand := func(args ...string) {
ui = new(testterm.FakeUI)
cmd := NewCreateSharedDomain(ui, configRepo, domainRepo)
testcmd.RunCommand(cmd, args, requirementsFactory)
return
}
It("TestShareDomainRequirements", func() {
runCommand("example.com")
Expect(testcmd.CommandDidPassRequirements).To(BeTrue())
requirementsFactory = &testreq.FakeReqFactory{LoginSuccess: false}
runCommand("example.com")