本文整理汇总了Golang中github.com/onsi/gomega/ghttp.Server.AllowUnhandledRequests方法的典型用法代码示例。如果您正苦于以下问题:Golang Server.AllowUnhandledRequests方法的具体用法?Golang Server.AllowUnhandledRequests怎么用?Golang Server.AllowUnhandledRequests使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/onsi/gomega/ghttp.Server
的用法示例。
在下文中一共展示了Server.AllowUnhandledRequests方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
logger = lagertest.NewTestLogger("test")
bbsPath = string(binaries["bbs"])
bbsAddress := fmt.Sprintf("127.0.0.1:%d", 13000+GinkgoParallelNode())
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()
示例2:
flushEvents chan struct{}
)
var getActualLRPGroups = func() []*models.ActualLRPGroup {
actualLRPGroups, err := bbsClient.ActualLRPGroups(models.ActualLRPFilter{})
Expect(err).NotTo(HaveOccurred())
return actualLRPGroups
}
BeforeEach(func() {
Eventually(getActualLRPGroups, 5*pollingInterval).Should(BeEmpty())
flushEvents = make(chan struct{})
fakeGarden = ghttp.NewUnstartedServer()
// these tests only look for the start of a sequence of requests
fakeGarden.AllowUnhandledRequests = false
fakeGarden.RouteToHandler("GET", "/ping", ghttp.RespondWithJSONEncoded(http.StatusOK, struct{}{}))
fakeGarden.RouteToHandler("GET", "/containers", ghttp.RespondWithJSONEncoded(http.StatusOK, struct{}{}))
fakeGarden.RouteToHandler("GET", "/capacity", ghttp.RespondWithJSONEncoded(http.StatusOK,
garden.Capacity{MemoryInBytes: 1024 * 1024 * 1024, DiskInBytes: 2048 * 1024 * 1024, MaxContainers: 4}))
fakeGarden.RouteToHandler("GET", "/containers/bulk_info", ghttp.RespondWithJSONEncoded(http.StatusOK, struct{}{}))
logger = lagertest.NewTestLogger("test")
serviceClient = bbs.NewServiceClient(consulSession, clock.NewClock())
pollingInterval = 50 * time.Millisecond
evacuationTimeout = 200 * time.Millisecond
rootFSName = "the-rootfs"
rootFSPath = "/path/to/rootfs"
rootFSArg := fmt.Sprintf("%s:%s", rootFSName, rootFSPath)
示例3:
Expect(err).NotTo(HaveOccurred())
listenerPath = string(binaries["listener"])
natsPort = 4001 + GinkgoParallelNode()
consulRunner = consulrunner.NewClusterRunner(
9001+config.GinkgoConfig.ParallelNode*consulrunner.PortOffsetLength,
1,
"http",
)
})
var _ = BeforeEach(func() {
consulRunner.Start()
consulRunner.WaitUntilReady()
consulClient = consulRunner.NewClient()
fakeBBS = ghttp.NewServer()
fakeBBS.AllowUnhandledRequests = false
})
var _ = AfterEach(func() {
consulRunner.Stop()
})
var _ = SynchronizedAfterSuite(func() {
}, func() {
gexec.CleanupBuildArtifacts()
})
示例4:
Expect(err).NotTo(HaveOccurred())
err = tw.Close()
Expect(err).NotTo(HaveOccurred())
err = gw.Close()
Expect(err).NotTo(HaveOccurred())
},
),
)
})
Context("when running with --output", func() {
Context("when the task specifies those outputs", func() {
It("downloads the tasks output to the directory provided", func() {
atcServer.AllowUnhandledRequests = true
flyCmd := exec.Command(flyPath, "-t", atcServer.URL(), "e", "-c", taskConfigPath, "--output", "some-dir="+outputDir)
flyCmd.Dir = buildDir
sess, err := gexec.Start(flyCmd, GinkgoWriter, GinkgoWriter)
Expect(err).NotTo(HaveOccurred())
// sync with after create
Eventually(streaming, 5.0).Should(BeClosed())
close(events)
<-sess.Exited
Expect(sess.ExitCode()).To(Equal(0))
示例5: TestVolman
"github.com/onsi/gomega/gexec"
"github.com/onsi/gomega/ghttp"
"testing"
)
var (
binaryPath string
fakeDriver *ghttp.Server
)
func TestVolman(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Volman Suite")
}
var _ = SynchronizedBeforeSuite(func() []byte {
var err error
binaryPath, err = gexec.Build("code.cloudfoundry.org/volman/cmd/volman", "-race")
Expect(err).NotTo(HaveOccurred())
return []byte(binaryPath)
}, func(bytes []byte) {
binaryPath = string(bytes)
})
var _ = BeforeEach(func() {
fakeDriver = ghttp.NewServer()
fakeDriver.AllowUnhandledRequests = true
})