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


Golang Server.URL方法代码示例

本文整理汇总了Golang中github.com/onsi/gomega/ghttp.Server.URL方法的典型用法代码示例。如果您正苦于以下问题:Golang Server.URL方法的具体用法?Golang Server.URL怎么用?Golang Server.URL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/onsi/gomega/ghttp.Server的用法示例。


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

示例1:

	"github.com/cloudfoundry-incubator/bbs/models"
	"github.com/cloudfoundry-incubator/cf_http"
	"github.com/cloudfoundry-incubator/rep"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/onsi/gomega/ghttp"
)

var _ = Describe("Client", func() {
	var fakeServer *ghttp.Server
	var client rep.Client

	BeforeEach(func() {
		fakeServer = ghttp.NewServer()
		client = rep.NewClient(cf_http.NewClient(), fakeServer.URL())
	})

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

	Describe("StopLRPInstance", func() {
		const cellAddr = "cell.example.com"
		var stopErr error
		var actualLRP = models.ActualLRP{
			ActualLRPKey:         models.NewActualLRPKey("some-process-guid", 2, "test-domain"),
			ActualLRPInstanceKey: models.NewActualLRPInstanceKey("some-instance-guid", "some-cell-id"),
		}

		JustBeforeEach(func() {
开发者ID:jianhuiz,项目名称:rep,代码行数:31,代码来源:client_test.go

示例2:

	bbsURL = &url.URL{
		Scheme: "http",
		Host:   bbsAddress,
	}

	bbsClient = bbs.NewClient(bbsURL.String())

	auctioneerServer = ghttp.NewServer()
	auctioneerServer.UnhandledRequestStatusCode = http.StatusAccepted
	auctioneerServer.AllowUnhandledRequests = true

	bbsArgs = bbstestrunner.Args{
		Address:           bbsAddress,
		AdvertiseURL:      bbsURL.String(),
		AuctioneerAddress: auctioneerServer.URL(),
		EtcdCluster:       strings.Join(etcdRunner.NodeURLS(), ","),
		ConsulCluster:     consulRunner.ConsulCluster(),

		EncryptionKeys: []string{"label:key"},
		ActiveKeyLabel: "label",
	}
})

var _ = BeforeEach(func() {
	etcdRunner.Start()
	consulRunner.Start()
	consulRunner.WaitUntilReady()

	bbsRunner = bbstestrunner.New(bbsPath, bbsArgs)
	bbsProcess = ginkgomon.Invoke(bbsRunner)
开发者ID:emc-xchallenge,项目名称:tps,代码行数:30,代码来源:main_suite_test.go

示例3:

		bulkerLockName    = "nsync_bulker_lock"
		pollingInterval   time.Duration
		heartbeatInterval time.Duration

		logger lager.Logger
	)

	startBulker := func(check bool) ifrit.Process {
		runner := ginkgomon.New(ginkgomon.Config{
			Name:          "nsync-bulker",
			AnsiColorCode: "97m",
			StartCheck:    "nsync.bulker.started",
			Command: exec.Command(
				bulkerPath,
				"-ccBaseURL", fakeCC.URL(),
				"-pollingInterval", pollingInterval.String(),
				"-domainTTL", domainTTL.String(),
				"-bulkBatchSize", "10",
				"-lifecycle", "buildpack/some-stack:some-health-check.tar.gz",
				"-lifecycle", "docker:the/docker/lifecycle/path.tgz",
				"-fileServerURL", "http://file-server.com",
				"-lockRetryInterval", "1s",
				"-consulCluster", consulRunner.ConsulCluster(),
				"-bbsAddress", fakeBBS.URL(),
				"-privilegedContainers", "false",
			),
		})

		if !check {
			runner.StartCheck = ""
开发者ID:cfibmers,项目名称:nsync,代码行数:30,代码来源:main_test.go

示例4:

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

	Describe("Post/PostCustomized", func() {
		It("makes a POST request with given payload", func() {
			server.AppendHandlers(
				ghttp.CombineHandlers(
					ghttp.VerifyRequest("POST", "/path"),
					ghttp.VerifyBody([]byte("post-request")),
					ghttp.RespondWith(http.StatusOK, []byte("post-response")),
				),
			)

			url := server.URL() + "/path"

			response, err := httpClient.Post(url, []byte("post-request"))
			Expect(err).ToNot(HaveOccurred())

			defer response.Body.Close()

			responseBody, err := ioutil.ReadAll(response.Body)
			Expect(err).ToNot(HaveOccurred())

			Expect(responseBody).To(Equal([]byte("post-response")))
			Expect(response.StatusCode).To(Equal(200))

			Expect(server.ReceivedRequests()).To(HaveLen(1))
		})
开发者ID:mattcui,项目名称:bosh-agent,代码行数:29,代码来源:http_client_test.go

示例5:

)

var _ = Describe("Testing misc requests", func() {

	var server *ghttp.Server
	var listener net.Listener
	var wstunsrv *WSTunnelServer
	var wstuncli *WSTunnelClient
	var wstunUrl string
	var wstunToken string

	BeforeEach(func() {
		// start ghttp to simulate target server
		wstunToken = "test567890123456-" + strconv.Itoa(rand.Int()%1000000)
		server = ghttp.NewServer()
		log15.Info("ghttp started", "url", server.URL())

		// start wstunsrv
		listener, _ = net.Listen("tcp", "127.0.0.1:0")
		wstunsrv = NewWSTunnelServer([]string{})
		wstunsrv.Start(listener)

		// start wstuncli
		wstuncli = NewWSTunnelClient([]string{
			"-token", wstunToken,
			"-tunnel", "ws://" + listener.Addr().String(),
			"-server", server.URL(),
			"-timeout", "3",
		})
		wstuncli.Start()
		wstunUrl = "http://" + listener.Addr().String()
开发者ID:rightscale,项目名称:wstunnel,代码行数:31,代码来源:misc_test.go

示例6:

					verifyBody("grant_type=client_credentials"),
					ghttp.RespondWithJSONEncoded(http.StatusOK, responseBody),
				))

			server.AppendHandlers(
				ghttp.CombineHandlers(
					ghttp.VerifyRequest("POST", "/v1/routes"),
					ghttp.VerifyHeader(http.Header{
						"Authorization": []string{"bearer " + token},
					}),
					ghttp.RespondWithJSONEncoded(http.StatusOK, nil),
				),
			)

			flags = []string{
				"-api", server.URL(),
				"-client-id", "some-name",
				"-client-secret", "some-secret",
				"-oauth-url", authServer.URL(),
			}
		})

		AfterEach(func() {
			authServer.Close()
			server.Close()
		})

		It("registers a route to the routing api", func() {
			command := buildCommand("register", flags, []string{`[{"route":"zak.com","port":3,"ip":"4"}]`})

			server.SetHandler(0,
开发者ID:markstgodard,项目名称:routing-api-cli,代码行数:31,代码来源:main_test.go

示例7:

				path, err = atc.Routes.CreatePathForRoute(atc.PausePipeline, rata.Params{"pipeline_name": "awesome-pipeline"})
				Expect(err).NotTo(HaveOccurred())
			})

			Context("when the pipeline exists", func() {
				BeforeEach(func() {
					atcServer.AppendHandlers(
						ghttp.CombineHandlers(
							ghttp.VerifyRequest("PUT", path),
							ghttp.RespondWith(http.StatusOK, nil),
						),
					)
				})

				It("pauses the pipeline", func() {
					flyCmd := exec.Command(flyPath, "-t", atcServer.URL(), "pause-pipeline", "-p", "awesome-pipeline")

					sess, err := gexec.Start(flyCmd, GinkgoWriter, GinkgoWriter)
					Expect(err).NotTo(HaveOccurred())

					Eventually(sess).Should(gbytes.Say(`paused 'awesome-pipeline'`))

					<-sess.Exited
					Expect(sess.ExitCode()).To(Equal(0))
					Expect(atcServer.ReceivedRequests()).To(HaveLen(1))
				})
			})

			Context("when the pipeline doesn't exist", func() {
				BeforeEach(func() {
					atcServer.AppendHandlers(
开发者ID:aemengo,项目名称:fly,代码行数:31,代码来源:pause_pipeline_test.go

示例8:

	"github.com/onsi/gomega/ghttp"
)

var _ = Describe("Testing xhost requests", func() {

	var server *ghttp.Server
	var wstuncli *WSTunnelClient
	var wstunsrv *WSTunnelServer
	var wstunUrl string
	var wstunToken string
	var cliStart func(server, regexp string) *WSTunnelClient

	BeforeEach(func() {
		wstunToken = "test567890123456-" + strconv.Itoa(rand.Int()%1000000)
		server = ghttp.NewServer()
		fmt.Fprintf(os.Stderr, "ghttp started on %s\n", server.URL())

		l, _ := net.Listen("tcp", "127.0.0.1:0")
		wstunsrv = NewWSTunnelServer([]string{})
		wstunsrv.Start(l)
		fmt.Fprintf(os.Stderr, "Server started\n")
		wstunUrl = "http://" + l.Addr().String()
		cliStart = func(server, regexp string) *WSTunnelClient {
			wstuncli = NewWSTunnelClient([]string{
				"-token", wstunToken, "-tunnel", "ws://" + l.Addr().String(),
				"-server", server, "-regexp", regexp,
			})
			wstuncli.Start()
			return wstuncli
		}
	})
开发者ID:ferdthebird,项目名称:wstunnel,代码行数:31,代码来源:xhost_test.go

示例9:

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/onsi/gomega/ghttp"
)

var _ = Describe("Flipkart", func() {
	var f *Flipkart
	var server *ghttp.Server

	BeforeEach(func() {
		server = ghttp.NewServer()
		f = &Flipkart{
			AffiliateId:   "fk-id",
			AffliateToken: "fk-secret",
			Host:          server.URL()[7:],
			Scheme:        "http",
		}
	})

	Context("TopOffers", func() {
		BeforeEach(func() {
			server.AppendHandlers(
				ghttp.CombineHandlers(
					ghttp.VerifyRequest("GET", "/affiliate/offers/v1/top/json"),
					ghttp.VerifyHeaderKV("Fk-Affiliate-Id", "fk-id"),
					ghttp.VerifyHeaderKV("Fk-Affiliate-Token", "fk-secret"),
					ghttp.RespondWith(200, topResult),
				))
		})
		It("retrieves the top offers", func() {
开发者ID:arangamani,项目名称:go-flipkart,代码行数:30,代码来源:flipkart_test.go

示例10:

		processGuid  string
		clientConfig *ssh.ClientConfig
	)

	BeforeEach(func() {
		fakeBBS = ghttp.NewServer()
		fakeUAA = ghttp.NewTLSServer()
		fakeCC = ghttp.NewTLSServer()

		privateKey, err := ssh.ParsePrivateKey([]byte(hostKeyPem))
		Expect(err).NotTo(HaveOccurred())
		hostKeyFingerprint = helpers.MD5Fingerprint(privateKey.PublicKey())

		address = fmt.Sprintf("127.0.0.1:%d", sshProxyPort)
		bbsAddress = fakeBBS.URL()
		ccAPIURL = fakeCC.URL()
		diegoCredentials = "some-creds"
		enableCFAuth = true
		enableDiegoAuth = true
		hostKey = hostKeyPem
		skipCertVerify = true
		processGuid = "app-guid-app-version"

		u, err := url.Parse(fakeUAA.URL())
		Expect(err).NotTo(HaveOccurred())

		u.Path = "/oauth/token"
		uaaTokenURL = u.String()
		uaaPassword = "password1"
		uaaUsername = "amandaplease"
开发者ID:swisscom,项目名称:diego-ssh,代码行数:30,代码来源:main_test.go

示例11:

var _ = Describe("HTTPProxyConfReader", func() {
	var (
		proxyConfReader *droplet_runner.HTTPProxyConfReader
		fakeServer      *ghttp.Server
		badURL          string
	)

	BeforeEach(func() {
		fakeServer = ghttp.NewServer()

		badServer := ghttp.NewServer()
		badURL = badServer.URL()
		badServer.Close()

		proxyConfReader = &droplet_runner.HTTPProxyConfReader{
			URL: fakeServer.URL() + "/pc.json",
		}
	})

	AfterEach(func() {
		if fakeServer != nil {
			fakeServer.Close()
		}
	})

	Context("#ProxyConf", func() {
		It("should parse JSON on 200", func() {
			fakeServer.RouteToHandler("GET", "/pc.json", ghttp.CombineHandlers(
				ghttp.RespondWith(200,
					`{"http_proxy": "http://proxy", "https_proxy": "https://proxy", "no_proxy": "no-proxy"}`,
					http.Header{"Content-Type": []string{"application/json"}},
开发者ID:SrinivasChilveri,项目名称:ltc,代码行数:31,代码来源:proxyconf_reader_test.go

示例12:

var _ = Describe("PivnetClient - product", func() {
	var (
		server     *ghttp.Server
		client     pivnet.Client
		token      string
		apiAddress string
		userAgent  string

		newClientConfig pivnet.NewClientConfig
		fakeLogger      logger.Logger
	)

	BeforeEach(func() {
		server = ghttp.NewServer()
		apiAddress = server.URL() + apiPrefix
		token = "my-auth-token"
		userAgent = "pivnet-resource/0.1.0 (some-url)"

		fakeLogger = &logger_fakes.FakeLogger{}
		newClientConfig = pivnet.NewClientConfig{
			URL:       apiAddress,
			Token:     token,
			UserAgent: userAgent,
		}
		client = pivnet.NewClient(newClientConfig, fakeLogger)
	})

	AfterEach(func() {
		server.Close()
	})
开发者ID:mdelillo,项目名称:pivnet-resource,代码行数:30,代码来源:products_test.go

示例13:

	"github.com/cloudfoundry-incubator/bbs/models"
	"github.com/cloudfoundry-incubator/ltc/blob_store/blob"
	"github.com/cloudfoundry-incubator/ltc/blob_store/dav_blob_store"
	config_package "github.com/cloudfoundry-incubator/ltc/config"
)

var _ = Describe("BlobStore", func() {
	var (
		blobStore      *dav_blob_store.BlobStore
		fakeServer     *ghttp.Server
		blobTargetInfo config_package.BlobStoreConfig
	)

	BeforeEach(func() {
		fakeServer = ghttp.NewServer()
		fakeServerURL, err := url.Parse(fakeServer.URL())
		Expect(err).NotTo(HaveOccurred())

		serverHost, serverPort, err := net.SplitHostPort(fakeServerURL.Host)
		Expect(err).NotTo(HaveOccurred())

		blobTargetInfo = config_package.BlobStoreConfig{
			Host:     serverHost,
			Port:     serverPort,
			Username: "user",
			Password: "pass",
		}

		blobStore = dav_blob_store.New(blobTargetInfo)
	})
开发者ID:SrinivasChilveri,项目名称:ltc,代码行数:30,代码来源:blob_store_test.go

示例14:

		expectedPlan = atc.Plan{
			OnSuccess: &atc.OnSuccessPlan{
				Step: atc.Plan{
					Aggregate: &atc.AggregatePlan{
						atc.Plan{
							Location: &atc.Location{
								ParallelGroup: 1,
								ParentID:      0,
								ID:            2,
							},
							Get: &atc.GetPlan{
								Name: filepath.Base(buildDir),
								Type: "archive",
								Source: atc.Source{
									"uri": atcServer.URL() + "/api/v1/pipes/some-pipe-id",
								},
							},
						},
					},
				},
				Next: atc.Plan{
					Ensure: &atc.EnsurePlan{
						Step: atc.Plan{
							Location: &atc.Location{
								ParallelGroup: 0,
								ParentID:      0,
								ID:            3,
							},
							Task: &atc.TaskPlan{
								Name: "one-off",
开发者ID:zankich,项目名称:fly,代码行数:30,代码来源:execute_with_outputs_test.go

示例15:

				request, apiErr = ccGateway.NewRequestForFile("PUT", "https://example.com/v2/apps", "BEARER my-access-token", f)
				Expect(apiErr).NotTo(HaveOccurred())
			})

			It("Uses a ProgressReader as the SeekableBody", func() {
				Expect(reflect.TypeOf(request.SeekableBody).String()).To(ContainSubstring("ProgressReader"))
			})

		})

	})

	Describe("PerformRequestForJSONResponse()", func() {
		BeforeEach(func() {
			ccServer = ghttp.NewServer()
			config.SetAPIEndpoint(ccServer.URL())
		})

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

		Context("When CC response with an api error", func() {
			BeforeEach(func() {
				ccServer.AppendHandlers(
					ghttp.CombineHandlers(
						ghttp.VerifyRequest("GET", "/v2/some-endpoint"),
						ghttp.VerifyHeader(http.Header{
							"accept": []string{"application/json"},
						}),
						ghttp.RespondWith(http.StatusUnauthorized, `{
开发者ID:yingkitw,项目名称:cli,代码行数:31,代码来源:gateway_test.go


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