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


Golang net.NewServer函数代码示例

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


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

示例1: testUploadApp

func testUploadApp(dir string, requests []testnet.TestRequest) (app models.Application, apiErr errors.Error) {
	ts, handler := testnet.NewServer(requests)
	defer ts.Close()

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

	var (
		reportedPath                          string
		reportedFileCount, reportedUploadSize uint64
	)
	apiErr = 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).To(testnet.HaveAllRequestsCalled())

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

示例2: setupAuthDependencies

func setupAuthDependencies(request testnet.TestRequest) (*httptest.Server, *testnet.TestHandler, configuration.ReadWriter) {
	ts, handler := testnet.NewServer([]testnet.TestRequest{request})
	config := testconfig.NewRepository()
	config.SetAuthenticationEndpoint(ts.URL)

	return ts, handler, config
}
开发者ID:knolleary,项目名称:cli,代码行数:7,代码来源:authentication_test.go

示例3: 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

示例4: createServiceRepoWithConfig

func createServiceRepoWithConfig(reqs []testnet.TestRequest, config configuration.ReadWriter) (testServer *httptest.Server, handler *testnet.TestHandler, repo ServiceRepository) {
	testServer, handler = testnet.NewServer(reqs)
	config.SetApiEndpoint(testServer.URL)

	gateway := net.NewCloudControllerGateway(config)
	repo = NewCloudControllerServiceRepository(config, gateway)
	return
}
开发者ID:juggernaut,项目名称:cli,代码行数:8,代码来源:services_test.go

示例5: 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

示例6: createServiceBindingRepo

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

示例7: createOrganizationRepo

func createOrganizationRepo(reqs ...testnet.TestRequest) (ts *httptest.Server, handler *testnet.TestHandler, repo OrganizationRepository) {
	ts, handler = testnet.NewServer(reqs)

	configRepo := testconfig.NewRepositoryWithDefaults()
	configRepo.SetApiEndpoint(ts.URL)
	gateway := net.NewCloudControllerGateway(configRepo)
	repo = NewCloudControllerOrganizationRepository(configRepo, gateway)
	return
}
开发者ID:julz,项目名称:cli,代码行数:9,代码来源:organizations_test.go

示例8: createPasswordRepo

func createPasswordRepo(req testnet.TestRequest) (passwordServer *httptest.Server, handler *testnet.TestHandler, repo PasswordRepository) {
	passwordServer, handler = testnet.NewServer([]testnet.TestRequest{req})

	configRepo := testconfig.NewRepositoryWithDefaults()
	configRepo.SetUaaEndpoint(passwordServer.URL)
	gateway := net.NewCloudControllerGateway(configRepo)
	repo = NewCloudControllerPasswordRepository(configRepo, gateway)
	return
}
开发者ID:knolleary,项目名称:cli,代码行数:9,代码来源:password_test.go

示例9: createAppInstancesRepo

func createAppInstancesRepo(requests []testnet.TestRequest) (ts *httptest.Server, handler *testnet.TestHandler, repo AppInstancesRepository) {
	ts, handler = testnet.NewServer(requests)
	space := models.SpaceFields{}
	space.Guid = "my-space-guid"
	configRepo := testconfig.NewRepositoryWithDefaults()
	configRepo.SetApiEndpoint(ts.URL)
	gateway := net.NewCloudControllerGateway()
	repo = NewCloudControllerAppInstancesRepository(configRepo, gateway)
	return
}
开发者ID:jibin-tomy,项目名称:cli,代码行数:10,代码来源:app_instances_test.go

示例10: createPasswordRepo

func createPasswordRepo(req testnet.TestRequest) (passwordServer *httptest.Server, handler *testnet.TestHandler, repo PasswordRepository) {
	passwordServer, handler = testnet.NewServer([]testnet.TestRequest{req})

	endpointRepo := &testapi.FakeEndpointRepo{}
	endpointRepo.UAAEndpointReturns.Endpoint = passwordServer.URL
	configRepo := testconfig.NewRepositoryWithDefaults()
	gateway := net.NewCloudControllerGateway()
	repo = NewCloudControllerPasswordRepository(configRepo, gateway, endpointRepo)
	return
}
开发者ID:jibin-tomy,项目名称:cli,代码行数:10,代码来源:password_test.go

示例11: createRoutesRepo

func createRoutesRepo(requests ...testnet.TestRequest) (ts *httptest.Server, handler *testnet.TestHandler, repo CloudControllerRouteRepository, domainRepo *testapi.FakeDomainRepository) {
	ts, handler = testnet.NewServer(requests)

	configRepo := testconfig.NewRepositoryWithDefaults()
	configRepo.SetApiEndpoint(ts.URL)
	gateway := net.NewCloudControllerGateway(configRepo)
	domainRepo = &testapi.FakeDomainRepository{}

	repo = NewCloudControllerRouteRepository(configRepo, gateway, domainRepo)
	return
}
开发者ID:knolleary,项目名称:cli,代码行数:11,代码来源:routes_test.go

示例12: setupEventTest

func setupEventTest(requests []testnet.TestRequest) (deps eventTestDependencies) {
	deps.server, deps.handler = testnet.NewServer(requests)

	configRepo := testconfig.NewRepository()
	configRepo.SetApiEndpoint(deps.server.URL)
	configRepo.SetAccessToken("BEARER my_access_token")

	deps.config = configRepo
	deps.gateway = net.NewCloudControllerGateway()

	return
}
开发者ID:jibin-tomy,项目名称:cli,代码行数:12,代码来源:app_events_test.go

示例13: createUsersRepo

func createUsersRepo(ccReqs []testnet.TestRequest, uaaReqs []testnet.TestRequest) (cc *httptest.Server,
	ccHandler *testnet.TestHandler, uaa *httptest.Server, uaaHandler *testnet.TestHandler, repo UserRepository) {

	ccTarget := ""
	uaaTarget := ""

	if len(ccReqs) > 0 {
		cc, ccHandler = testnet.NewServer(ccReqs)
		ccTarget = cc.URL
	}
	if len(uaaReqs) > 0 {
		uaa, uaaHandler = testnet.NewServer(uaaReqs)
		uaaTarget = uaa.URL
	}

	configRepo := testconfig.NewRepositoryWithDefaults()
	configRepo.SetApiEndpoint(ccTarget)
	ccGateway := net.NewCloudControllerGateway(configRepo)
	uaaGateway := net.NewUAAGateway(configRepo)
	configRepo.SetUaaEndpoint(uaaTarget)
	repo = NewCloudControllerUserRepository(configRepo, uaaGateway, ccGateway)
	return
}
开发者ID:knolleary,项目名称:cli,代码行数:23,代码来源:users_test.go

示例14:

		repo              CloudControllerBuildpackBitsRepository
		buildpack         models.Buildpack
		testServer        *httptest.Server
		testServerHandler *testnet.TestHandler
	)

	BeforeEach(func() {
		gateway := net.NewCloudControllerGateway(configRepo)
		pwd, _ := os.Getwd()

		buildpacksDir = filepath.Join(pwd, "../../fixtures/buildpacks")
		configRepo = testconfig.NewRepositoryWithDefaults()
		repo = NewCloudControllerBuildpackBitsRepository(configRepo, gateway, app_files.ApplicationZipper{})
		buildpack = models.Buildpack{Name: "my-cool-buildpack", Guid: "my-cool-buildpack-guid"}

		testServer, testServerHandler = testnet.NewServer([]testnet.TestRequest{uploadBuildpackRequest()})
		configRepo.SetApiEndpoint(testServer.URL)
	})

	AfterEach(func() {
		testServer.Close()
	})

	Describe("#UploadBuildpack", func() {
		It("fails to upload a buildpack with an invalid directory", func() {
			apiErr := repo.UploadBuildpack(buildpack, "/foo/bar")
			Expect(apiErr).NotTo(BeNil())
			Expect(apiErr.Error()).To(ContainSubstring("Error opening buildpack file"))
		})

		It("uploads a valid buildpack directory", func() {
开发者ID:knolleary,项目名称:cli,代码行数:31,代码来源:buildpack_bits_test.go

示例15:

		domainRepo = &testapi.FakeDomainRepository{}
		repo = NewCloudControllerRouteRepository(configRepo, gateway, domainRepo)
	})

	AfterEach(func() {
		ts.Close()
	})

	Describe("List routes", func() {
		It("lists routes in the current space", func() {
			ts, handler = testnet.NewServer([]testnet.TestRequest{
				testapi.NewCloudControllerTestRequest(testnet.TestRequest{
					Method:   "GET",
					Path:     "/v2/spaces/the-space-guid/routes?inline-relations-depth=1",
					Response: firstPageRoutesResponse,
				}),
				testapi.NewCloudControllerTestRequest(testnet.TestRequest{
					Method:   "GET",
					Path:     "/v2/spaces/the-space-guid/routes?inline-relations-depth=1&page=2",
					Response: secondPageRoutesResponse,
				}),
			})
			configRepo.SetApiEndpoint(ts.URL)

			routes := []models.Route{}
			apiErr := repo.ListRoutes(func(route models.Route) bool {
				routes = append(routes, route)
				return true
			})

			Expect(len(routes)).To(Equal(2))
			Expect(routes[0].Guid).To(Equal("route-1-guid"))
开发者ID:nota-ja,项目名称:cli,代码行数:32,代码来源:routes_test.go


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