本文整理汇总了Golang中testhelpers/configuration.NewRepositoryWithAccessToken函数的典型用法代码示例。如果您正苦于以下问题:Golang NewRepositoryWithAccessToken函数的具体用法?Golang NewRepositoryWithAccessToken怎么用?Golang NewRepositoryWithAccessToken使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewRepositoryWithAccessToken函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: callShareDomain
func callShareDomain(args []string, reqFactory *testreq.FakeReqFactory, domainRepo *testapi.FakeDomainRepository) (fakeUI *testterm.FakeUI) {
fakeUI = new(testterm.FakeUI)
ctxt := testcmd.NewContext("create-shared-domain", args)
configRepo := testconfig.NewRepositoryWithAccessToken(configuration.TokenInfo{Username: "my-user"})
cmd := NewCreateSharedDomain(fakeUI, configRepo, domainRepo)
testcmd.RunCommand(cmd, ctxt, reqFactory)
return
}
示例2: callListDomains
func callListDomains(args []string, reqFactory *testreq.FakeReqFactory, domainRepo *testapi.FakeDomainRepository) (fakeUI *testterm.FakeUI) {
fakeUI = new(testterm.FakeUI)
ctxt := testcmd.NewContext("domains", args)
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, ctxt, reqFactory)
return
}
示例3: callCreateRoute
func callCreateRoute(args []string, requirementsFactory *testreq.FakeReqFactory, routeRepo *testapi.FakeRouteRepository) (fakeUI *testterm.FakeUI) {
fakeUI = new(testterm.FakeUI)
ctxt := testcmd.NewContext("create-route", args)
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 := NewCreateRoute(fakeUI, configRepo, routeRepo)
testcmd.RunCommand(cmd, ctxt, requirementsFactory)
return
}
示例4: callListQuotas
func callListQuotas(reqFactory *testreq.FakeReqFactory, quotaRepo *testapi.FakeQuotaRepository) (fakeUI *testterm.FakeUI) {
fakeUI = &testterm.FakeUI{}
ctxt := testcmd.NewContext("quotas", []string{})
spaceFields := models.SpaceFields{}
spaceFields.Name = "my-space"
orgFields := models.OrganizationFields{}
orgFields.Name = "my-org"
token := configuration.TokenInfo{Username: "my-user"}
config := testconfig.NewRepositoryWithAccessToken(token)
config.SetSpaceFields(spaceFields)
config.SetOrganizationFields(orgFields)
cmd := organization.NewListQuotas(fakeUI, config, quotaRepo)
testcmd.RunCommand(cmd, ctxt, reqFactory)
return
}
示例5: callShowOrg
func callShowOrg(args []string, reqFactory *testreq.FakeReqFactory) (ui *testterm.FakeUI) {
ui = new(testterm.FakeUI)
ctxt := testcmd.NewContext("org", args)
token := configuration.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)
cmd := NewShowOrg(ui, configRepo)
testcmd.RunCommand(cmd, ctxt, reqFactory)
return
}
示例6: callDeleteSharedDomain
func callDeleteSharedDomain(args []string, inputs []string, deps deleteSharedDomainDependencies) (ui *testterm.FakeUI) {
ctxt := testcmd.NewContext("delete-domain", args)
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, ctxt, deps.requirementsFactory)
return
}
示例7: callCreateOrg
func callCreateOrg(args []string, requirementsFactory *testreq.FakeReqFactory, orgRepo *testapi.FakeOrgRepository) (fakeUI *testterm.FakeUI) {
fakeUI = new(testterm.FakeUI)
ctxt := testcmd.NewContext("create-org", args)
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, ctxt, requirementsFactory)
return
}
示例8:
{"Not logged in", "Use", "log in"},
})
})
})
Context("when an api endpoint is set and the user logged in", func() {
var config configuration.ReadWriter
BeforeEach(func() {
accessToken := configuration.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 = captureOutput(func() {
ui := NewUI(os.Stdin)
ui.ShowConfiguration(config)
})
})
It("tells the user which api endpoint is set", func() {
示例9:
space := models.SpaceFields{}
space.Guid = "my-space-guid"
space.Name = "my-space"
domain := models.DomainFields{}
domain.Guid = "domain-guid"
domain.Name = "example.com"
createdRoute := models.Route{}
createdRoute.Host = "my-host"
createdRoute.Guid = "my-route-guid"
routeRepo := &testapi.FakeRouteRepository{
CreateInSpaceCreatedRoute: createdRoute,
}
ui := new(testterm.FakeUI)
configRepo := testconfig.NewRepositoryWithAccessToken(configuration.TokenInfo{Username: "my-user"})
orgFields := models.OrganizationFields{}
orgFields.Name = "my-org"
configRepo.SetOrganizationFields(orgFields)
cmd := NewCreateRoute(ui, configRepo, routeRepo)
route, apiErr := cmd.CreateRoute("my-host", domain, space)
Expect(route.Guid).To(Equal(createdRoute.Guid))
Expect(apiErr).NotTo(HaveOccurred())
testassert.SliceContains(ui.Outputs, testassert.Lines{
{"Creating route", "my-host.example.com", "my-org", "my-space", "my-user"},
{"OK"},
})
示例10:
org1 := models.Organization{}
org1.Name = "Organization-1"
org2 := models.Organization{}
org2.Name = "Organization-2"
org3 := models.Organization{}
org3.Name = "Organization-3"
orgRepo := &testapi.FakeOrgRepository{
Organizations: []models.Organization{org1, org2, org3},
}
reqFactory := &testreq.FakeReqFactory{LoginSuccess: true}
tokenInfo := configuration.TokenInfo{Username: "my-user"}
config := testconfig.NewRepositoryWithAccessToken(tokenInfo)
ui := callListOrgs(config, reqFactory, orgRepo)
testassert.SliceContains(ui.Outputs, testassert.Lines{
{"Getting orgs as my-user"},
{"Organization-1"},
{"Organization-2"},
{"Organization-3"},
})
})
It("TestListNoOrgs", func() {
orgs := []models.Organization{}
orgRepo := &testapi.FakeOrgRepository{
Organizations: orgs,