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


Golang configuration.NewRepositoryWithDefaults函数代码示例

本文整理汇总了Golang中testhelpers/configuration.NewRepositoryWithDefaults函数的典型用法代码示例。如果您正苦于以下问题:Golang NewRepositoryWithDefaults函数的具体用法?Golang NewRepositoryWithDefaults怎么用?Golang NewRepositoryWithDefaults使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了NewRepositoryWithDefaults函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

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

示例2: setupTestServerAndLogsRepo

func setupTestServerAndLogsRepo(messages ...[]byte) (testServer *httptest.Server, requestHandler *requestHandlerWithExpectedPath, logsRepo *LoggregatorLogsRepository) {
	requestHandler = new(requestHandlerWithExpectedPath)
	requestHandler.handlerFunc = func(conn *websocket.Conn) {
		request := conn.Request()
		requestHandler.lastPath = request.URL.Path
		Expect(request.URL.RawQuery).To(Equal("app=my-app-guid"))
		Expect(request.Method).To(Equal("GET"))
		Expect(request.Header.Get("Authorization")).To(ContainSubstring("BEARER my_access_token"))

		for _, msg := range messages {
			conn.Write(msg)
		}
		time.Sleep(time.Duration(50) * time.Millisecond)
		conn.Close()
	}

	testServer = httptest.NewTLSServer(websocket.Handler(requestHandler.handlerFunc))

	configRepo := testconfig.NewRepositoryWithDefaults()
	configRepo.SetApiEndpoint("https://localhost")
	endpointRepo := &testapi.FakeEndpointRepo{}
	endpointRepo.LoggregatorEndpointReturns.Endpoint = strings.Replace(testServer.URL, "https", "wss", 1)

	repo := NewLoggregatorLogsRepository(configRepo, endpointRepo)
	logsRepo = &repo
	return
}
开发者ID:jibin-tomy,项目名称:cli,代码行数:27,代码来源:logs_test.go

示例3: testUploadApp

func testUploadApp(dir string, requests []testnet.TestRequest) (app models.Application, apiResponse net.ApiResponse) {
	ts, handler := testnet.NewTLSServer(requests)
	defer ts.Close()

	configRepo := testconfig.NewRepositoryWithDefaults()
	configRepo.SetApiEndpoint(ts.URL)
	gateway := net.NewCloudControllerGateway()
	gateway.PollingThrottle = time.Duration(0)
	zipper := cf.ApplicationZipper{}
	repo := NewCloudControllerApplicationBitsRepository(configRepo, gateway, zipper)

	var (
		reportedPath                          string
		reportedFileCount, reportedUploadSize uint64
	)
	apiResponse = repo.UploadApp("my-cool-app-guid", dir, func(path string, uploadSize, fileCount uint64) {
		reportedPath = path
		reportedUploadSize = uploadSize
		reportedFileCount = fileCount
	})

	Expect(reportedPath).To(Equal(dir))
	Expect(reportedFileCount).To(Equal(uint64(len(expectedApplicationContent))))
	Expect(reportedUploadSize).To(Equal(uint64(759)))
	Expect(handler.AllRequestsCalled()).To(BeTrue())

	return
}
开发者ID:normalnorman,项目名称:cli,代码行数:28,代码来源:application_bits_test.go

示例4: callRenameSpace

func callRenameSpace(args []string, reqFactory *testreq.FakeReqFactory, spaceRepo *testapi.FakeSpaceRepository) (ui *testterm.FakeUI) {
	ui = new(testterm.FakeUI)
	ctxt := testcmd.NewContext("create-space", args)
	configRepo := testconfig.NewRepositoryWithDefaults()
	cmd := NewRenameSpace(ui, configRepo, spaceRepo)
	testcmd.RunCommand(cmd, ctxt, reqFactory)
	return
}
开发者ID:normalnorman,项目名称:cli,代码行数:8,代码来源:rename_space_test.go

示例5: createServiceAuthTokenRepo

func createServiceAuthTokenRepo(request testnet.TestRequest) (ts *httptest.Server, handler *testnet.TestHandler, repo ServiceAuthTokenRepository) {
	ts, handler = testnet.NewTLSServer([]testnet.TestRequest{request})
	configRepo := testconfig.NewRepositoryWithDefaults()
	configRepo.SetApiEndpoint(ts.URL)
	gateway := net.NewCloudControllerGateway()
	repo = NewCloudControllerServiceAuthTokenRepository(configRepo, gateway)
	return
}
开发者ID:nimbus-cloud,项目名称:cli,代码行数:8,代码来源:service_auth_tokens_test.go

示例6: createBuildpackRepo

func createBuildpackRepo(requests ...testnet.TestRequest) (ts *httptest.Server, handler *testnet.TestHandler, repo BuildpackRepository) {
	ts, handler = testnet.NewTLSServer(requests)
	config := testconfig.NewRepositoryWithDefaults()
	config.SetApiEndpoint(ts.URL)
	gateway := net.NewCloudControllerGateway()
	repo = NewCloudControllerBuildpackRepository(config, gateway)
	return
}
开发者ID:normalnorman,项目名称:cli,代码行数:8,代码来源:buildpacks_test.go

示例7: createUserProvidedServiceInstanceRepo

func createUserProvidedServiceInstanceRepo(req testnet.TestRequest) (ts *httptest.Server, handler *testnet.TestHandler, repo UserProvidedServiceInstanceRepository) {
	ts, handler = testnet.NewServer([]testnet.TestRequest{req})
	configRepo := testconfig.NewRepositoryWithDefaults()
	configRepo.SetApiEndpoint(ts.URL)
	gateway := net.NewCloudControllerGateway(configRepo)
	repo = NewCCUserProvidedServiceInstanceRepository(configRepo, gateway)
	return
}
开发者ID:knolleary,项目名称:cli,代码行数:8,代码来源:user_provided_service_instances_test.go

示例8: createSpacesRepo

func createSpacesRepo(reqs ...testnet.TestRequest) (ts *httptest.Server, handler *testnet.TestHandler, repo SpaceRepository) {
	ts, handler = testnet.NewServer(reqs)
	configRepo := testconfig.NewRepositoryWithDefaults()
	configRepo.SetApiEndpoint(ts.URL)
	gateway := net.NewCloudControllerGateway(configRepo)
	repo = NewCloudControllerSpaceRepository(configRepo, gateway)
	return
}
开发者ID:nota-ja,项目名称:cli,代码行数:8,代码来源:spaces_test.go

示例9: createAppSummaryRepo

func createAppSummaryRepo(requests []testnet.TestRequest) (ts *httptest.Server, handler *testnet.TestHandler, repo AppSummaryRepository) {
	ts, handler = testnet.NewTLSServer(requests)
	configRepo := testconfig.NewRepositoryWithDefaults()
	configRepo.SetApiEndpoint(ts.URL)
	gateway := net.NewCloudControllerGateway()
	repo = NewCloudControllerAppSummaryRepository(configRepo, gateway)
	return
}
开发者ID:normalnorman,项目名称:cli,代码行数:8,代码来源:app_summary_test.go

示例10: callCreateServiceBroker

func callCreateServiceBroker(args []string, requirementsFactory *testreq.FakeReqFactory, serviceBrokerRepo *testapi.FakeServiceBrokerRepo) (ui *testterm.FakeUI) {
	ui = &testterm.FakeUI{}
	ctxt := testcmd.NewContext("create-service-broker", args)
	config := testconfig.NewRepositoryWithDefaults()
	cmd := NewCreateServiceBroker(ui, config, serviceBrokerRepo)
	testcmd.RunCommand(cmd, ctxt, requirementsFactory)
	return
}
开发者ID:nota-ja,项目名称:cli,代码行数:8,代码来源:create_service_broker_test.go

示例11: callSetEnv

func callSetEnv(args []string, reqFactory *testreq.FakeReqFactory, appRepo api.ApplicationRepository) (ui *testterm.FakeUI) {
	ui = new(testterm.FakeUI)
	ctxt := testcmd.NewContext("set-env", args)
	configRepo := testconfig.NewRepositoryWithDefaults()
	cmd := NewSetEnv(ui, configRepo, appRepo)
	testcmd.RunCommand(cmd, ctxt, reqFactory)
	return
}
开发者ID:knolleary,项目名称:cli,代码行数:8,代码来源:set_env_test.go

示例12: callRenameOrg

func callRenameOrg(args []string, reqFactory *testreq.FakeReqFactory, orgRepo *testapi.FakeOrgRepository) (ui *testterm.FakeUI) {
	ui = new(testterm.FakeUI)
	ctxt := testcmd.NewContext("rename-org", args)
	configRepo := testconfig.NewRepositoryWithDefaults()
	cmd := organization.NewRenameOrg(ui, configRepo, orgRepo)
	testcmd.RunCommand(cmd, ctxt, reqFactory)
	return
}
开发者ID:normalnorman,项目名称:cli,代码行数:8,代码来源:rename_org_test.go

示例13: callScale

func callScale(args []string, deps scaleDependencies) (ui *testterm.FakeUI) {
	ui = new(testterm.FakeUI)
	ctxt := testcmd.NewContext("scale", args)
	configRepo := testconfig.NewRepositoryWithDefaults()
	cmd := NewScale(ui, configRepo, deps.restarter, deps.appRepo)
	testcmd.RunCommand(cmd, ctxt, deps.reqFactory)
	return
}
开发者ID:normalnorman,项目名称:cli,代码行数:8,代码来源:scale_test.go

示例14: createDomainRepo

func createDomainRepo(reqs []testnet.TestRequest) (ts *httptest.Server, handler *testnet.TestHandler, repo DomainRepository) {
	ts, handler = testnet.NewServer(reqs)
	config := testconfig.NewRepositoryWithDefaults()
	config.SetApiEndpoint(ts.URL)
	gateway := net.NewCloudControllerGateway()
	repo = NewCloudControllerDomainRepository(config, gateway)
	return
}
开发者ID:jibin-tomy,项目名称:cli,代码行数:8,代码来源:domains_test.go

示例15: callLogs

func callLogs(args []string, requirementsFactory *testreq.FakeReqFactory, logsRepo *testapi.FakeLogsRepository) (ui *testterm.FakeUI) {
	ui = new(testterm.FakeUI)
	ctxt := testcmd.NewContext("logs", args)

	configRepo := testconfig.NewRepositoryWithDefaults()
	cmd := NewLogs(ui, configRepo, logsRepo)
	testcmd.RunCommand(cmd, ctxt, requirementsFactory)
	return
}
开发者ID:nota-ja,项目名称:cli,代码行数:9,代码来源:logs_test.go


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