本文整理汇总了Golang中testhelpers/commands.RunCommand函数的典型用法代码示例。如果您正苦于以下问题:Golang RunCommand函数的具体用法?Golang RunCommand怎么用?Golang RunCommand使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RunCommand函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestPushingRequirements
func TestPushingRequirements(t *testing.T) {
ui := new(testterm.FakeUI)
config := &configuration.Configuration{}
deps := getPushDependencies()
manifestRepo := deps.manifestRepo
starter := deps.starter
stopper := deps.stopper
binder := deps.binder
appRepo := deps.appRepo
domainRepo := deps.domainRepo
routeRepo := deps.routeRepo
stackRepo := deps.stackRepo
appBitsRepo := deps.appBitsRepo
serviceRepo := deps.serviceRepo
cmd := NewPush(ui, config, manifestRepo, starter, stopper, binder, appRepo, domainRepo, routeRepo, stackRepo, serviceRepo, appBitsRepo)
ctxt := testcmd.NewContext("push", []string{})
reqFactory := &testreq.FakeReqFactory{LoginSuccess: true, TargetedSpaceSuccess: true}
assert.True(t, testcmd.CommandDidPassRequirements)
reqFactory = &testreq.FakeReqFactory{LoginSuccess: false, TargetedSpaceSuccess: true}
testcmd.RunCommand(cmd, ctxt, reqFactory)
assert.False(t, testcmd.CommandDidPassRequirements)
testcmd.CommandDidPassRequirements = true
reqFactory = &testreq.FakeReqFactory{LoginSuccess: true, TargetedSpaceSuccess: false}
testcmd.RunCommand(cmd, ctxt, reqFactory)
assert.False(t, testcmd.CommandDidPassRequirements)
}
示例2: deleteApp
func deleteApp(t *testing.T, confirmation string, args []string) (ui *testterm.FakeUI, reqFactory *testreq.FakeReqFactory, appRepo *testapi.FakeApplicationRepository) {
app := cf.Application{}
app.Name = "app-to-delete"
app.Guid = "app-to-delete-guid"
reqFactory = &testreq.FakeReqFactory{}
appRepo = &testapi.FakeApplicationRepository{ReadApp: app}
ui = &testterm.FakeUI{
Inputs: []string{confirmation},
}
token, err := testconfig.CreateAccessTokenWithTokenInfo(configuration.TokenInfo{
Username: "my-user",
})
assert.NoError(t, err)
org := cf.OrganizationFields{}
org.Name = "my-org"
space := cf.SpaceFields{}
space.Name = "my-space"
config := &configuration.Configuration{
SpaceFields: space,
OrganizationFields: org,
AccessToken: token,
}
ctxt := testcmd.NewContext("delete", args)
cmd := NewDeleteApp(ui, config, appRepo)
testcmd.RunCommand(cmd, ctxt, reqFactory)
return
}
示例3: callRenameOrg
func callRenameOrg(t *testing.T, args []string, reqFactory *testreq.FakeReqFactory, orgRepo *testapi.FakeOrgRepository) (ui *testterm.FakeUI) {
ui = new(testterm.FakeUI)
ctxt := testcmd.NewContext("rename-org", args)
token, err := testconfig.CreateAccessTokenWithTokenInfo(configuration.TokenInfo{
Username: "my-user",
})
assert.NoError(t, err)
spaceFields := cf.SpaceFields{}
spaceFields.Name = "my-space"
orgFields := cf.OrganizationFields{}
orgFields.Name = "my-org"
config := &configuration.Configuration{
SpaceFields: spaceFields,
OrganizationFields: orgFields,
AccessToken: token,
}
cmd := organization.NewRenameOrg(ui, config, orgRepo)
testcmd.RunCommand(cmd, ctxt, reqFactory)
return
}
示例4: callDeleteDomain
func callDeleteDomain(t *testing.T, args []string, inputs []string, reqFactory *testreq.FakeReqFactory, domainRepo *testapi.FakeDomainRepository) (ui *testterm.FakeUI) {
ctxt := testcmd.NewContext("delete-domain", args)
ui = &testterm.FakeUI{
Inputs: inputs,
}
token, err := testconfig.CreateAccessTokenWithTokenInfo(configuration.TokenInfo{
Username: "my-user",
})
assert.NoError(t, err)
spaceFields := cf.SpaceFields{}
spaceFields.Name = "my-space"
orgFields := cf.OrganizationFields{}
orgFields.Name = "my-org"
config := &configuration.Configuration{
SpaceFields: spaceFields,
OrganizationFields: orgFields,
AccessToken: token,
}
cmd := domain.NewDeleteDomain(ui, config, domainRepo)
testcmd.RunCommand(cmd, ctxt, reqFactory)
return
}
示例5: callDomainMapper
func callDomainMapper(t *testing.T, shouldMap bool, args []string, reqFactory *testreq.FakeReqFactory, domainRepo *testapi.FakeDomainRepository) (ui *testterm.FakeUI) {
cmdName := "map-domain"
if !shouldMap {
cmdName = "unmap-domain"
}
ctxt := testcmd.NewContext(cmdName, args)
ui = &testterm.FakeUI{}
token, err := testconfig.CreateAccessTokenWithTokenInfo(configuration.TokenInfo{
Username: "my-user",
})
assert.NoError(t, err)
orgFields := cf.OrganizationFields{}
orgFields.Name = "my-org"
spaceFields := cf.SpaceFields{}
spaceFields.Name = "my-space"
config := &configuration.Configuration{
SpaceFields: spaceFields,
OrganizationFields: orgFields,
AccessToken: token,
}
cmd := domain.NewDomainMapper(ui, config, domainRepo, shouldMap)
testcmd.RunCommand(cmd, ctxt, reqFactory)
return
}
示例6: callDeleteServiceAuthToken
func callDeleteServiceAuthToken(t *testing.T, args []string, inputs []string, reqFactory *testreq.FakeReqFactory, authTokenRepo *testapi.FakeAuthTokenRepo) (ui *testterm.FakeUI) {
ui = &testterm.FakeUI{
Inputs: inputs,
}
token, err := testconfig.CreateAccessTokenWithTokenInfo(configuration.TokenInfo{
Username: "my-user",
})
assert.NoError(t, err)
org := cf.OrganizationFields{}
org.Name = "my-org"
space := cf.SpaceFields{}
space.Name = "my-space"
config := &configuration.Configuration{
SpaceFields: space,
OrganizationFields: org,
AccessToken: token,
}
cmd := NewDeleteServiceAuthToken(ui, config, authTokenRepo)
ctxt := testcmd.NewContext("delete-service-auth-token", args)
testcmd.RunCommand(cmd, ctxt, reqFactory)
return
}
示例7: callAuthenticate
func callAuthenticate(args []string, configRepo configuration.ConfigurationRepository, auth api.AuthenticationRepository) (ui *testterm.FakeUI) {
ui = new(testterm.FakeUI)
ctxt := testcmd.NewContext("auth", args)
cmd := NewAuthenticate(ui, configRepo, auth)
testcmd.RunCommand(cmd, ctxt, &testreq.FakeReqFactory{})
return
}
示例8: callStacks
func callStacks(t *testing.T, stackRepo *testapi.FakeStackRepository) (ui *testterm.FakeUI) {
ui = &testterm.FakeUI{}
ctxt := testcmd.NewContext("stacks", []string{})
token, err := testconfig.CreateAccessTokenWithTokenInfo(configuration.TokenInfo{
Username: "my-user",
})
assert.NoError(t, err)
space := cf.SpaceFields{}
space.Name = "my-space"
org := cf.OrganizationFields{}
org.Name = "my-org"
config := &configuration.Configuration{
SpaceFields: space,
OrganizationFields: org,
AccessToken: token,
}
cmd := NewStacks(ui, config, stackRepo)
testcmd.RunCommand(cmd, ctxt, nil)
return
}
示例9: deleteWithConfirmation
func deleteWithConfirmation(confirmation string) (ui *testterm.FakeUI, userRepo *testapi.FakeUserRepository) {
ui = &testterm.FakeUI{
Inputs: []string{confirmation},
}
user2 := models.UserFields{}
user2.Username = "my-found-user"
user2.Guid = "my-found-user-guid"
userRepo = &testapi.FakeUserRepository{
FindByUsernameUserFields: user2,
}
configRepo := testconfig.NewRepositoryWithDefaults()
accessToken, err := testconfig.EncodeAccessToken(configuration.TokenInfo{
Username: "current-user",
})
Expect(err).NotTo(HaveOccurred())
configRepo.SetAccessToken(accessToken)
cmd := NewDeleteUser(ui, configRepo, userRepo)
ctxt := testcmd.NewContext("delete-user", []string{"my-user"})
reqFactory := &testreq.FakeReqFactory{LoginSuccess: true}
testcmd.RunCommand(cmd, ctxt, reqFactory)
return
}
示例10: deleteServiceBroker
func deleteServiceBroker(t *testing.T, confirmation string, args []string) (ui *testterm.FakeUI, reqFactory *testreq.FakeReqFactory, repo *testapi.FakeServiceBrokerRepo) {
serviceBroker := cf.ServiceBroker{
Name: "service-broker-to-delete",
Guid: "service-broker-to-delete-guid",
}
reqFactory = &testreq.FakeReqFactory{LoginSuccess: true}
repo = &testapi.FakeServiceBrokerRepo{FindByNameServiceBroker: serviceBroker}
ui = &testterm.FakeUI{
Inputs: []string{confirmation},
}
token, err := testconfig.CreateAccessTokenWithTokenInfo(configuration.TokenInfo{
Username: "my-user",
})
assert.NoError(t, err)
config := &configuration.Configuration{
Space: cf.Space{Name: "my-space"},
Organization: cf.Organization{Name: "my-org"},
AccessToken: token,
}
ctxt := testcmd.NewContext("delete-service-broker", args)
cmd := NewDeleteServiceBroker(ui, config, repo)
testcmd.RunCommand(cmd, ctxt, reqFactory)
return
}
示例11: callListQuotas
func callListQuotas(t *testing.T, reqFactory *testreq.FakeReqFactory, quotaRepo *testapi.FakeQuotaRepository) (fakeUI *testterm.FakeUI) {
fakeUI = &testterm.FakeUI{}
ctxt := testcmd.NewContext("quotas", []string{})
token, err := testconfig.CreateAccessTokenWithTokenInfo(configuration.TokenInfo{
Username: "my-user",
})
assert.NoError(t, err)
spaceFields := cf.SpaceFields{}
spaceFields.Name = "my-space"
orgFields := cf.OrganizationFields{}
orgFields.Name = "my-org"
config := &configuration.Configuration{
SpaceFields: spaceFields,
OrganizationFields: orgFields,
AccessToken: token,
}
cmd := organization.NewListQuotas(fakeUI, config, quotaRepo)
testcmd.RunCommand(cmd, ctxt, reqFactory)
return
}
示例12: callListRoutes
func callListRoutes(t *testing.T, args []string, reqFactory *testreq.FakeReqFactory, routeRepo *testapi.FakeRouteRepository) (ui *testterm.FakeUI) {
ui = &testterm.FakeUI{}
ctxt := testcmd.NewContext("routes", args)
token, err := testconfig.CreateAccessTokenWithTokenInfo(configuration.TokenInfo{
Username: "my-user",
})
assert.NoError(t, err)
space := cf.SpaceFields{}
space.Name = "my-space"
org := cf.OrganizationFields{}
org.Name = "my-org"
config := &configuration.Configuration{
SpaceFields: space,
OrganizationFields: org,
AccessToken: token,
}
cmd := NewListRoutes(ui, config, routeRepo)
testcmd.RunCommand(cmd, ctxt, reqFactory)
return
}
示例13: callListBuildpacks
func callListBuildpacks(requirementsFactory *testreq.FakeReqFactory, buildpackRepo *testapi.FakeBuildpackRepository) (ui *testterm.FakeUI) {
ui = &testterm.FakeUI{}
ctxt := testcmd.NewContext("buildpacks", []string{})
cmd := buildpack.NewListBuildpacks(ui, buildpackRepo)
testcmd.RunCommand(cmd, ctxt, requirementsFactory)
return
}
示例14: deleteSpace
func deleteSpace(t *testing.T, confirmation string, args []string) (ui *testterm.FakeUI, spaceRepo *testapi.FakeSpaceRepository) {
space := cf.Space{Name: "space-to-delete", Guid: "space-to-delete-guid"}
reqFactory := &testreq.FakeReqFactory{}
spaceRepo = &testapi.FakeSpaceRepository{FindByNameSpace: space}
configRepo := &testconfig.FakeConfigRepository{}
ui = &testterm.FakeUI{
Inputs: []string{confirmation},
}
ctxt := testcmd.NewContext("delete-space", args)
token, err := testconfig.CreateAccessTokenWithTokenInfo(configuration.TokenInfo{
Username: "my-user",
})
assert.NoError(t, err)
config := &configuration.Configuration{
Space: cf.Space{Name: "my-space"},
Organization: cf.Organization{Name: "my-org"},
AccessToken: token,
}
cmd := NewDeleteSpace(ui, config, spaceRepo, configRepo)
testcmd.RunCommand(cmd, ctxt, reqFactory)
return
}
示例15: TestDeleteBuildpackSuccess
func TestDeleteBuildpackSuccess(t *testing.T) {
ui := &testterm.FakeUI{Inputs: []string{"y"}}
buildpack := cf.Buildpack{}
buildpack.Name = "my-buildpack"
buildpack.Guid = "my-buildpack-guid"
buildpackRepo := &testapi.FakeBuildpackRepository{
FindByNameBuildpack: buildpack,
}
cmd := NewDeleteBuildpack(ui, buildpackRepo)
ctxt := testcmd.NewContext("delete-buildpack", []string{"my-buildpack"})
reqFactory := &testreq.FakeReqFactory{LoginSuccess: true}
testcmd.RunCommand(cmd, ctxt, reqFactory)
assert.Equal(t, buildpackRepo.DeleteBuildpackGuid, "my-buildpack-guid")
testassert.SliceContains(t, ui.Prompts, testassert.Lines{
{"delete", "my-buildpack"},
})
testassert.SliceContains(t, ui.Outputs, testassert.Lines{
{"Deleting buildpack", "my-buildpack"},
{"OK"},
})
}