當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。