本文整理汇总了Golang中testhelpers/requirements.FakeReqFactory类的典型用法代码示例。如果您正苦于以下问题:Golang FakeReqFactory类的具体用法?Golang FakeReqFactory怎么用?Golang FakeReqFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FakeReqFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: startAppWithInstancesAndErrors
func startAppWithInstancesAndErrors(displayApp ApplicationDisplayer, app models.Application, instances [][]models.AppInstanceFields, errorCodes []string, requirementsFactory *testreq.FakeReqFactory) (ui *testterm.FakeUI, appRepo *testapi.FakeApplicationRepository, appInstancesRepo *testapi.FakeAppInstancesRepo) {
configRepo := testconfig.NewRepositoryWithDefaults()
appRepo = &testapi.FakeApplicationRepository{
UpdateAppResult: app,
}
appRepo.ReadReturns.App = app
appInstancesRepo = &testapi.FakeAppInstancesRepo{
GetInstancesResponses: instances,
GetInstancesErrorCodes: errorCodes,
}
logRepo := &testapi.FakeLogsRepository{
TailLogMessages: []*logmessage.Message{
NewLogMessage("Log Line 1", app.Guid, LogMessageTypeStaging, time.Now()),
NewLogMessage("Log Line 2", app.Guid, LogMessageTypeStaging, time.Now()),
},
}
args := []string{"my-app"}
requirementsFactory.Application = app
ui = callStart(args, configRepo, requirementsFactory, displayApp, appRepo, appInstancesRepo, logRepo)
return
}
示例2:
"cf/configuration"
"cf/models"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
testapi "testhelpers/api"
testassert "testhelpers/assert"
testcmd "testhelpers/commands"
testconfig "testhelpers/configuration"
testreq "testhelpers/requirements"
testterm "testhelpers/terminal"
)
var _ = Describe("target command", func() {
var (
orgRepo *testapi.FakeOrgRepository
spaceRepo *testapi.FakeSpaceRepository
config configuration.ReadWriter
reqFactory *testreq.FakeReqFactory
)
BeforeEach(func() {
orgRepo, spaceRepo, config, reqFactory = getTargetDependencies()
})
It("fails with usage when called without -o or -s", func() {
ui := callTarget([]string{"bad-foo"}, reqFactory, config, orgRepo, spaceRepo)
Expect(ui.FailedWithUsage).To(BeTrue())
})
It("fails requirements when targeting a space or org", func() {
callTarget([]string{"-o", "some-crazy-org-im-not-in"}, reqFactory, config, orgRepo, spaceRepo)
Expect(testcmd.CommandDidPassRequirements).To(BeFalse())
示例3:
"cf/configuration"
"cf/models"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
testapi "testhelpers/api"
testassert "testhelpers/assert"
testcmd "testhelpers/commands"
testconfig "testhelpers/configuration"
testreq "testhelpers/requirements"
testterm "testhelpers/terminal"
)
var _ = Describe("delete-org command", func() {
var (
config configuration.ReadWriter
ui *testterm.FakeUI
requirementsFactory *testreq.FakeReqFactory
orgRepo *testapi.FakeOrgRepository
)
BeforeEach(func() {
ui = &testterm.FakeUI{
Inputs: []string{"y"},
}
config = testconfig.NewRepositoryWithDefaults()
requirementsFactory = &testreq.FakeReqFactory{}
org := models.Organization{}
org.Name = "org-to-delete"
org.Guid = "org-to-delete-guid"
orgRepo = &testapi.FakeOrgRepository{Organizations: []models.Organization{org}}
})
示例4:
. "cf/commands/service"
"cf/configuration"
"cf/models"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
testapi "testhelpers/api"
testassert "testhelpers/assert"
testcmd "testhelpers/commands"
testconfig "testhelpers/configuration"
testreq "testhelpers/requirements"
testterm "testhelpers/terminal"
)
var _ = Describe("Marketplace Services", func() {
var ui *testterm.FakeUI
var reqFactory *testreq.FakeReqFactory
var config configuration.ReadWriter
var serviceRepo *testapi.FakeServiceRepo
var fakeServiceOfferings []models.ServiceOffering
BeforeEach(func() {
serviceRepo = &testapi.FakeServiceRepo{}
ui = &testterm.FakeUI{}
reqFactory = &testreq.FakeReqFactory{ApiEndpointSuccess: true}
fakeServiceOfferings = []models.ServiceOffering{
models.ServiceOffering{
Plans: []models.ServicePlanFields{
models.ServicePlanFields{Name: "service-plan-a"},
models.ServicePlanFields{Name: "service-plan-b"},
},
示例5:
"cf/models"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
testapi "testhelpers/api"
testassert "testhelpers/assert"
testcmd "testhelpers/commands"
testconfig "testhelpers/configuration"
testreq "testhelpers/requirements"
testterm "testhelpers/terminal"
"time"
)
var _ = Describe("events command", func() {
var (
requirementsFactory *testreq.FakeReqFactory
eventsRepo *testapi.FakeAppEventsRepo
ui *testterm.FakeUI
)
const TIMESTAMP_FORMAT = "2006-01-02T15:04:05.00-0700"
BeforeEach(func() {
eventsRepo = &testapi.FakeAppEventsRepo{}
requirementsFactory = &testreq.FakeReqFactory{LoginSuccess: true, TargetedSpaceSuccess: true}
ui = new(testterm.FakeUI)
})
runCommand := func(args ...string) {
configRepo := testconfig.NewRepositoryWithDefaults()
cmd := NewEvents(ui, configRepo, eventsRepo)
testcmd.RunCommand(cmd, testcmd.NewContext("events", args), requirementsFactory)
示例6:
. "cf/commands/organization"
"cf/models"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
testapi "testhelpers/api"
testassert "testhelpers/assert"
testcmd "testhelpers/commands"
testconfig "testhelpers/configuration"
testreq "testhelpers/requirements"
testterm "testhelpers/terminal"
)
var _ = Describe("set-quota command", func() {
var (
cmd *SetQuota
ui *testterm.FakeUI
quotaRepo *testapi.FakeQuotaRepository
requirementsFactory *testreq.FakeReqFactory
)
runCommand := func(args ...string) {
testcmd.RunCommand(cmd, testcmd.NewContext("set-quota", args), requirementsFactory)
}
BeforeEach(func() {
ui = new(testterm.FakeUI)
quotaRepo = &testapi.FakeQuotaRepository{}
requirementsFactory = &testreq.FakeReqFactory{}
cmd = NewSetQuota(ui, testconfig.NewRepositoryWithDefaults(), quotaRepo)
})
It("fails with usage when provided too many or two few args", func() {
示例7:
import (
. "cf/commands/buildpack"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
testapi "testhelpers/api"
testassert "testhelpers/assert"
testcmd "testhelpers/commands"
testreq "testhelpers/requirements"
testterm "testhelpers/terminal"
)
var _ = Describe("create-buildpack command", func() {
var (
requirementsFactory *testreq.FakeReqFactory
repo *testapi.FakeBuildpackRepository
bitsRepo *testapi.FakeBuildpackBitsRepository
ui *testterm.FakeUI
cmd CreateBuildpack
)
BeforeEach(func() {
requirementsFactory = &testreq.FakeReqFactory{LoginSuccess: true}
repo = &testapi.FakeBuildpackRepository{}
bitsRepo = &testapi.FakeBuildpackBitsRepository{}
ui = &testterm.FakeUI{}
cmd = NewCreateBuildpack(ui, repo, bitsRepo)
})
It("fails requirements when the user is not logged in", func() {
requirementsFactory.LoginSuccess = false
context := testcmd.NewContext("create-buildpack", []string{"my-buildpack", "my-dir", "0"})
示例8:
import (
"cf/commands/organization"
"cf/models"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
testapi "testhelpers/api"
testassert "testhelpers/assert"
testcmd "testhelpers/commands"
testconfig "testhelpers/configuration"
testreq "testhelpers/requirements"
testterm "testhelpers/terminal"
)
var _ = Describe("rename-org command", func() {
var reqFactory *testreq.FakeReqFactory
var orgRepo *testapi.FakeOrgRepository
BeforeEach(func() {
reqFactory = &testreq.FakeReqFactory{}
orgRepo = &testapi.FakeOrgRepository{}
})
It("fails with usage when given less than two args", func() {
ui := callRenameOrg([]string{}, reqFactory, orgRepo)
Expect(ui.FailedWithUsage).To(BeTrue())
ui = callRenameOrg([]string{"foo"}, reqFactory, orgRepo)
Expect(ui.FailedWithUsage).To(BeTrue())
})
示例9:
"cf/models"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
testapi "testhelpers/api"
testassert "testhelpers/assert"
testcmd "testhelpers/commands"
testconfig "testhelpers/configuration"
testreq "testhelpers/requirements"
testterm "testhelpers/terminal"
)
var _ = Describe("delete-domain command", func() {
var (
cmd *DeleteDomain
ui *testterm.FakeUI
configRepo configuration.ReadWriter
domainRepo *testapi.FakeDomainRepository
requirementsFactory *testreq.FakeReqFactory
)
BeforeEach(func() {
ui = &testterm.FakeUI{
Inputs: []string{"yes"},
}
domainRepo = &testapi.FakeDomainRepository{}
requirementsFactory = &testreq.FakeReqFactory{
LoginSuccess: true,
TargetedOrgSuccess: true,
}
configRepo = testconfig.NewRepositoryWithDefaults()
示例10:
"cf/api"
. "cf/commands/application"
"cf/models"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
testapi "testhelpers/api"
testassert "testhelpers/assert"
testcmd "testhelpers/commands"
testconfig "testhelpers/configuration"
testreq "testhelpers/requirements"
testterm "testhelpers/terminal"
)
var _ = Describe("stop command", func() {
var (
requirementsFactory *testreq.FakeReqFactory
)
BeforeEach(func() {
requirementsFactory = &testreq.FakeReqFactory{}
})
It("fails requirements when not logged in", func() {
requirementsFactory.LoginSuccess = false
appRepo := &testapi.FakeApplicationRepository{}
cmd := NewStop(new(testterm.FakeUI), testconfig.NewRepository(), appRepo)
testcmd.RunCommand(cmd, testcmd.NewContext("stop", []string{"some-app-name"}), requirementsFactory)
Expect(testcmd.CommandDidPassRequirements).To(BeFalse())
})
示例11:
import (
. "cf/commands/buildpack"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
testapi "testhelpers/api"
testassert "testhelpers/assert"
testcmd "testhelpers/commands"
testreq "testhelpers/requirements"
testterm "testhelpers/terminal"
)
var _ = Describe("create-buildpack command", func() {
var (
reqFactory *testreq.FakeReqFactory
repo *testapi.FakeBuildpackRepository
bitsRepo *testapi.FakeBuildpackBitsRepository
ui *testterm.FakeUI
cmd CreateBuildpack
)
BeforeEach(func() {
reqFactory = &testreq.FakeReqFactory{LoginSuccess: true}
repo = &testapi.FakeBuildpackRepository{}
bitsRepo = &testapi.FakeBuildpackBitsRepository{}
ui = &testterm.FakeUI{}
cmd = NewCreateBuildpack(ui, repo, bitsRepo)
})
It("fails requirements when the user is not logged in", func() {
reqFactory.LoginSuccess = false
context := testcmd.NewContext("create-buildpack", []string{"my-buildpack", "my-dir", "0"})
示例12:
"cf/models"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
testapi "testhelpers/api"
testassert "testhelpers/assert"
testcmd "testhelpers/commands"
testconfig "testhelpers/configuration"
testreq "testhelpers/requirements"
testterm "testhelpers/terminal"
"time"
)
var _ = Describe("events command", func() {
var (
reqFactory *testreq.FakeReqFactory
eventsRepo *testapi.FakeAppEventsRepo
ui *testterm.FakeUI
)
BeforeEach(func() {
eventsRepo = &testapi.FakeAppEventsRepo{}
reqFactory = &testreq.FakeReqFactory{LoginSuccess: true, TargetedSpaceSuccess: true}
ui = new(testterm.FakeUI)
})
runCommand := func(args ...string) {
configRepo := testconfig.NewRepositoryWithDefaults()
cmd := NewEvents(ui, configRepo, eventsRepo)
testcmd.RunCommand(cmd, testcmd.NewContext("events", args), reqFactory)
}
示例13:
"cf/models"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
testapi "testhelpers/api"
testassert "testhelpers/assert"
testcmd "testhelpers/commands"
testconfig "testhelpers/configuration"
testreq "testhelpers/requirements"
testterm "testhelpers/terminal"
)
var _ = Describe("auth command", func() {
var (
ui *testterm.FakeUI
cmd Authenticate
config configuration.ReadWriter
repo *testapi.FakeAuthenticationRepository
reqFactory *testreq.FakeReqFactory
)
BeforeEach(func() {
ui = &testterm.FakeUI{}
config = testconfig.NewRepositoryWithDefaults()
reqFactory = &testreq.FakeReqFactory{}
repo = &testapi.FakeAuthenticationRepository{
Config: config,
AccessToken: "my-access-token",
RefreshToken: "my-refresh-token",
}
cmd = NewAuthenticate(ui, config, repo)
})
示例14:
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
testapi "testhelpers/api"
testassert "testhelpers/assert"
testcmd "testhelpers/commands"
testconfig "testhelpers/configuration"
"testhelpers/maker"
testreq "testhelpers/requirements"
testterm "testhelpers/terminal"
)
var _ = Describe("scale command", func() {
var (
reqFactory *testreq.FakeReqFactory
restarter *testcmd.FakeAppRestarter
appRepo *testapi.FakeApplicationRepository
ui *testterm.FakeUI
configRepo configuration.Repository
cmd *Scale
)
BeforeEach(func() {
reqFactory = &testreq.FakeReqFactory{LoginSuccess: true, TargetedSpaceSuccess: true}
restarter = &testcmd.FakeAppRestarter{}
appRepo = &testapi.FakeApplicationRepository{}
ui = new(testterm.FakeUI)
configRepo = testconfig.NewRepositoryWithDefaults()
cmd = NewScale(ui, configRepo, restarter, appRepo)
})
Describe("requirements", func() {
It("requires the user to be logged in with a targed space", func() {
示例15:
"cf/api"
. "cf/commands/service"
"cf/models"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
testapi "testhelpers/api"
testassert "testhelpers/assert"
testcmd "testhelpers/commands"
testconfig "testhelpers/configuration"
testreq "testhelpers/requirements"
testterm "testhelpers/terminal"
)
var _ = Describe("bind-service command", func() {
var (
requirementsFactory *testreq.FakeReqFactory
)
BeforeEach(func() {
requirementsFactory = &testreq.FakeReqFactory{}
})
It("fails requirements when not logged in", func() {
context := testcmd.NewContext("bind-service", []string{"service", "app"})
cmd := NewBindService(&testterm.FakeUI{}, testconfig.NewRepository(), &testapi.FakeServiceBindingRepo{})
testcmd.RunCommand(cmd, context, requirementsFactory)
Expect(testcmd.CommandDidPassRequirements).To(BeFalse())
})
Context("when logged in", func() {