本文整理汇总了Golang中github.com/cloudfoundry/cli/testhelpers/net.NewServer函数的典型用法代码示例。如果您正苦于以下问题:Golang NewServer函数的具体用法?Golang NewServer怎么用?Golang NewServer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewServer函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
}
开发者ID:Reejoshi,项目名称:cli,代码行数:8,代码来源:service_summary_test.go
示例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
}
开发者ID:vframbach,项目名称:cli,代码行数:8,代码来源:applications_test.go
示例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
}
开发者ID:yingkitw,项目名称:cli,代码行数:8,代码来源:applications_test.go
示例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
}
开发者ID:herchu,项目名称:cli,代码行数:8,代码来源:service_brokers_test.go
示例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
}
开发者ID:yingkitw,项目名称:cli,代码行数:8,代码来源:service_summary_test.go
示例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
}
开发者ID:GABONIA,项目名称:cli,代码行数:8,代码来源:user_provided_service_instances_test.go
示例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
}
开发者ID:jsloyer,项目名称:cli,代码行数:8,代码来源:user_provided_service_instances_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 := cloudcontrollergateway.NewTestCloudControllerGateway(configRepo)
repo = NewCloudControllerPasswordRepository(configRepo, gateway)
return
}
开发者ID:yingkitw,项目名称:cli,代码行数:9,代码来源:password_test.go
示例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
}
开发者ID:Reejoshi,项目名称:cli,代码行数:9,代码来源:password_test.go
示例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
}
开发者ID:matanzit,项目名称:cli,代码行数:9,代码来源:organizations_test.go
示例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
}
开发者ID:Reejoshi,项目名称:cli,代码行数:10,代码来源:app_instances_test.go
示例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
}
开发者ID:BlueSpice,项目名称:cli,代码行数:10,代码来源:app_instances_test.go
示例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,
},
}),
)
开发者ID:Reejoshi,项目名称:cli,代码行数:31,代码来源:staging_test.go
示例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"))
开发者ID:jsloyer,项目名称:cli,代码行数:32,代码来源:routes_test.go
示例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"))
开发者ID:Jack1996,项目名称:cli,代码行数:32,代码来源:routes_test.go
示例16:
config configuration.ReadWriter
repo BuildpackRepository
)
BeforeEach(func() {
config = testconfig.NewRepositoryWithDefaults()
gateway := net.NewCloudControllerGateway((config), time.Now)
repo = NewCloudControllerBuildpackRepository(config, gateway)
})
AfterEach(func() {
ts.Close()
})
var setupTestServer = func(requests ...testnet.TestRequest) {
ts, handler = testnet.NewServer(requests)
config.SetApiEndpoint(ts.URL)
}
It("lists buildpacks", func() {
setupTestServer(
testapi.NewCloudControllerTestRequest(testnet.TestRequest{
Method: "GET",
Path: "/v2/buildpacks",
Response: testnet.TestResponse{
Status: http.StatusOK,
Body: `{
"next_url": "/v2/buildpacks?page=2",
"resources": [
{
"metadata": {
开发者ID:Jack1996,项目名称:cli,代码行数:31,代码来源:buildpacks_test.go
示例17:
ccGateway := net.NewCloudControllerGateway((config), time.Now)
uaaGateway := net.NewUAAGateway(config)
repo = NewCloudControllerUserRepository(config, uaaGateway, ccGateway)
})
AfterEach(func() {
if uaaServer != nil {
uaaServer.Close()
}
if ccServer != nil {
ccServer.Close()
}
})
setupCCServer := func(requests ...testnet.TestRequest) {
ccServer, ccHandler = testnet.NewServer(requests)
config.SetApiEndpoint(ccServer.URL)
}
setupUAAServer := func(requests ...testnet.TestRequest) {
uaaServer, uaaHandler = testnet.NewServer(requests)
config.SetUaaEndpoint(uaaServer.URL)
}
Describe("listing the users with a given role", func() {
Context("when there are no users in the given org", func() {
It("lists the users in a org with a given role", func() {
ccReqs := []testnet.TestRequest{
testapi.NewCloudControllerTestRequest(testnet.TestRequest{
Method: "GET",
Path: "/v2/organizations/my-org-guid/managers",
开发者ID:palakmathur,项目名称:cli,代码行数:31,代码来源:users_test.go
示例18:
listFilesServer := httptest.NewServer(http.HandlerFunc(listFilesEndpoint))
defer listFilesServer.Close()
req := apifakes.NewCloudControllerTestRequest(testnet.TestRequest{
Method: "GET",
Path: "/v2/apps/my-app-guid/instances/1/files/some/path",
Response: testnet.TestResponse{
Status: http.StatusTemporaryRedirect,
Header: http.Header{
"Location": {fmt.Sprintf("%s/some/path", listFilesServer.URL)},
},
},
})
listFilesRedirectServer, handler := testnet.NewServer([]testnet.TestRequest{req})
defer listFilesRedirectServer.Close()
configRepo := testconfig.NewRepositoryWithDefaults()
configRepo.SetAPIEndpoint(listFilesRedirectServer.URL)
gateway := cloudcontrollergateway.NewTestCloudControllerGateway(configRepo)
repo := NewCloudControllerAppFilesRepository(configRepo, gateway)
list, err := repo.ListFiles("my-app-guid", 1, "some/path")
Expect(handler).To(HaveAllRequestsCalled())
Expect(err).ToNot(HaveOccurred())
Expect(list).To(Equal(expectedResponse))
})
})
开发者ID:yingkitw,项目名称:cli,代码行数:29,代码来源:app_files_test.go
示例19:
deps.config = testconfig.NewRepository()
deps.config.SetAccessToken("BEARER my_access_token")
deps.gateway = net.NewCloudControllerGateway(deps.config, time.Now)
return
}
var _ = Describe("curl command", func() {
It("TestCurlGetRequest", func() {
req := testapi.NewCloudControllerTestRequest(testnet.TestRequest{
Method: "GET",
Path: "/v2/endpoint",
Response: testnet.TestResponse{
Status: http.StatusOK,
Body: expectedJSONResponse},
})
ts, handler := testnet.NewServer([]testnet.TestRequest{req})
defer ts.Close()
deps := newCurlDependencies()
deps.config.SetApiEndpoint(ts.URL)
repo := NewCloudControllerCurlRepository(deps.config, deps.gateway)
headers, body, apiErr := repo.Request("GET", "/v2/endpoint", "", "")
Expect(handler).To(testnet.HaveAllRequestsCalled())
Expect(headers).To(ContainSubstring("200"))
Expect(headers).To(ContainSubstring("Content-Type"))
Expect(headers).To(ContainSubstring("text/plain"))
testassert.JSONStringEquals(body, expectedJSONResponse)
Expect(apiErr).NotTo(HaveOccurred())
})
开发者ID:palakmathur,项目名称:cli,代码行数:31,代码来源:curl_test.go
示例20:
config core_config.ReadWriter
auth AuthenticationRepository
)
BeforeEach(func() {
config = testconfig.NewRepository()
gateway = net.NewUAAGateway(config, &testterm.FakeUI{})
auth = NewUAAAuthenticationRepository(gateway, config)
})
AfterEach(func() {
testServer.Close()
})
var setupTestServer = func(request testnet.TestRequest) {
testServer, handler = testnet.NewServer([]testnet.TestRequest{request})
config.SetAuthenticationEndpoint(testServer.URL)
}
Describe("authenticating", func() {
var err error
JustBeforeEach(func() {
err = auth.Authenticate(map[string]string{
"username": "[email protected]",
"password": "bar",
})
})
Describe("when login succeeds", func() {
BeforeEach(func() {
开发者ID:mandarjog,项目名称:cli,代码行数:31,代码来源:authentication_test.go
注:本文中的github.com/cloudfoundry/cli/testhelpers/net.NewServer函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论