本文整理匯總了Golang中github.com/cloudfoundry/cli/testhelpers/net.NewServer函數的典型用法代碼示例。如果您正苦於以下問題:Golang NewServer函數的具體用法?Golang NewServer怎麽用?Golang NewServer使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了NewServer函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: createServiceSummaryRepo
func createServiceSummaryRepo(req testnet.TestRequest) (ts *httptest.Server, handler *testnet.TestHandler, repo ServiceSummaryRepository) {
ts, handler = testnet.NewServer([]testnet.TestRequest{req})
configRepo := testconfig.NewRepositoryWithDefaults()
configRepo.SetAPIEndpoint(ts.URL)
gateway := net.NewCloudControllerGateway(configRepo, time.Now, new(terminalfakes.FakeUI), new(tracefakes.FakePrinter), "")
repo = NewCloudControllerServiceSummaryRepository(configRepo, gateway)
return
}
示例2: createAppRepo
func createAppRepo(requests []testnet.TestRequest) (ts *httptest.Server, handler *testnet.TestHandler, repo ApplicationRepository) {
ts, handler = testnet.NewServer(requests)
configRepo := testconfig.NewRepositoryWithDefaults()
configRepo.SetApiEndpoint(ts.URL)
gateway := net.NewCloudControllerGateway(configRepo, time.Now, &testterm.FakeUI{})
repo = NewCloudControllerApplicationRepository(configRepo, gateway)
return
}
示例3: createAppRepo
func createAppRepo(requests []testnet.TestRequest) (ts *httptest.Server, handler *testnet.TestHandler, repo ApplicationRepository) {
ts, handler = testnet.NewServer(requests)
configRepo := testconfig.NewRepositoryWithDefaults()
configRepo.SetAPIEndpoint(ts.URL)
gateway := cloudcontrollergateway.NewTestCloudControllerGateway(configRepo)
repo = NewCloudControllerApplicationRepository(configRepo, gateway)
return
}
示例4: createServiceBrokerRepo
func createServiceBrokerRepo(requests ...testnet.TestRequest) (ts *httptest.Server, handler *testnet.TestHandler, repo ServiceBrokerRepository) {
ts, handler = testnet.NewServer(requests)
configRepo := testconfig.NewRepositoryWithDefaults()
configRepo.SetApiEndpoint(ts.URL)
gateway := net.NewCloudControllerGateway(configRepo, time.Now)
repo = NewCloudControllerServiceBrokerRepository(configRepo, gateway)
return
}
示例5: createServiceSummaryRepo
func createServiceSummaryRepo(req testnet.TestRequest) (ts *httptest.Server, handler *testnet.TestHandler, repo ServiceSummaryRepository) {
ts, handler = testnet.NewServer([]testnet.TestRequest{req})
configRepo := testconfig.NewRepositoryWithDefaults()
configRepo.SetAPIEndpoint(ts.URL)
gateway := cloudcontrollergateway.NewTestCloudControllerGateway(configRepo)
repo = NewCloudControllerServiceSummaryRepository(configRepo, gateway)
return
}
示例6: 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, time.Now)
repo = NewCCUserProvidedServiceInstanceRepository(configRepo, gateway)
return
}
示例7: createUserProvidedServiceInstanceRepo
func createUserProvidedServiceInstanceRepo(req []testnet.TestRequest) (ts *httptest.Server, handler *testnet.TestHandler, repo UserProvidedServiceInstanceRepository) {
ts, handler = testnet.NewServer(req)
configRepo := testconfig.NewRepositoryWithDefaults()
configRepo.SetAPIEndpoint(ts.URL)
gateway := net.NewCloudControllerGateway(configRepo, time.Now, new(terminalfakes.FakeUI), new(tracefakes.FakePrinter))
repo = NewCCUserProvidedServiceInstanceRepository(configRepo, gateway)
return
}
示例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 := cloudcontrollergateway.NewTestCloudControllerGateway(configRepo)
repo = NewCloudControllerPasswordRepository(configRepo, gateway)
return
}
示例9: createPasswordRepo
func createPasswordRepo(req testnet.TestRequest) (passwordServer *httptest.Server, handler *testnet.TestHandler, repo Repository) {
passwordServer, handler = testnet.NewServer([]testnet.TestRequest{req})
configRepo := testconfig.NewRepositoryWithDefaults()
configRepo.SetUaaEndpoint(passwordServer.URL)
gateway := net.NewCloudControllerGateway(configRepo, time.Now, new(terminalfakes.FakeUI), new(tracefakes.FakePrinter), "")
repo = NewCloudControllerRepository(configRepo, gateway)
return
}
示例10: createOrganizationRepo
func createOrganizationRepo(reqs ...testnet.TestRequest) (testserver *httptest.Server, handler *testnet.TestHandler, repo OrganizationRepository) {
testserver, handler = testnet.NewServer(reqs)
configRepo := testconfig.NewRepositoryWithDefaults()
configRepo.SetApiEndpoint(testserver.URL)
gateway := net.NewCloudControllerGateway(configRepo, time.Now)
repo = NewCloudControllerOrganizationRepository(configRepo, gateway)
return
}
示例11: createAppInstancesRepo
func createAppInstancesRepo(requests []testnet.TestRequest) (ts *httptest.Server, handler *testnet.TestHandler, repo Repository) {
ts, handler = testnet.NewServer(requests)
space := models.SpaceFields{}
space.GUID = "my-space-guid"
configRepo := testconfig.NewRepositoryWithDefaults()
configRepo.SetAPIEndpoint(ts.URL)
gateway := net.NewCloudControllerGateway(configRepo, time.Now, new(terminalfakes.FakeUI), new(tracefakes.FakePrinter), "")
repo = NewCloudControllerAppInstancesRepository(configRepo, gateway)
return
}
示例12: 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(configRepo, time.Now)
repo = NewCloudControllerAppInstancesRepository(configRepo, gateway)
return
}
示例13:
configRepo coreconfig.ReadWriter
repo SecurityGroupsRepo
)
BeforeEach(func() {
configRepo = testconfig.NewRepositoryWithDefaults()
gateway := net.NewCloudControllerGateway(configRepo, time.Now, new(terminalfakes.FakeUI), new(tracefakes.FakePrinter), "")
repo = NewSecurityGroupsRepo(configRepo, gateway)
})
AfterEach(func() {
testServer.Close()
})
setupTestServer := func(reqs ...testnet.TestRequest) {
testServer, testHandler = testnet.NewServer(reqs)
configRepo.SetAPIEndpoint(testServer.URL)
}
Describe("BindToStagingSet", func() {
It("makes a correct request", func() {
setupTestServer(
apifakes.NewCloudControllerTestRequest(testnet.TestRequest{
Method: "PUT",
Path: "/v2/config/staging_security_groups/a-real-guid",
Response: testnet.TestResponse{
Status: http.StatusCreated,
Body: bindStagingResponse,
},
}),
)
示例14:
})
AfterEach(func() {
if ts != nil {
ts.Close()
}
})
Describe("List routes", func() {
It("lists routes in the current space", func() {
ts, handler = testnet.NewServer([]testnet.TestRequest{
apifakes.NewCloudControllerTestRequest(testnet.TestRequest{
Method: "GET",
Path: "/v2/spaces/the-space-guid/routes?inline-relations-depth=1",
Response: firstPageRoutesResponse,
}),
apifakes.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"))
示例15:
gateway := net.NewCloudControllerGateway((configRepo), time.Now)
repo = NewCloudControllerRouteRepository(configRepo, gateway)
})
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"))