当前位置: 首页>>代码示例>>Golang>>正文


Golang requirements.FakeReqFactory类代码示例

本文整理汇总了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
}
开发者ID:julz,项目名称:cli,代码行数:24,代码来源:start_test.go

示例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())
开发者ID:jibin-tomy,项目名称:cli,代码行数:32,代码来源:target_test.go

示例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}}
	})
开发者ID:nota-ja,项目名称:cli,代码行数:32,代码来源:delete_org_test.go

示例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"},
				},
开发者ID:julz,项目名称:cli,代码行数:31,代码来源:marketplace_services_test.go

示例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)
开发者ID:nota-ja,项目名称:cli,代码行数:31,代码来源:events_test.go

示例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() {
开发者ID:nota-ja,项目名称:cli,代码行数:32,代码来源:set_quota_test.go

示例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"})
开发者ID:nota-ja,项目名称:cli,代码行数:31,代码来源:create_buildpack_test.go

示例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())
	})
开发者ID:normalnorman,项目名称:cli,代码行数:29,代码来源:rename_org_test.go

示例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()
开发者ID:nota-ja,项目名称:cli,代码行数:31,代码来源:delete_domain_test.go

示例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())
	})
开发者ID:nota-ja,项目名称:cli,代码行数:30,代码来源:stop_test.go

示例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"})
开发者ID:knolleary,项目名称:cli,代码行数:31,代码来源:create_buildpack_test.go

示例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)
	}
开发者ID:julz,项目名称:cli,代码行数:30,代码来源:events_test.go

示例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)
	})
开发者ID:knolleary,项目名称:cli,代码行数:31,代码来源:authenticate_test.go

示例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() {
开发者ID:knolleary,项目名称:cli,代码行数:32,代码来源:scale_test.go

示例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() {
开发者ID:nota-ja,项目名称:cli,代码行数:31,代码来源:bind_service_test.go


注:本文中的testhelpers/requirements.FakeReqFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。