本文整理汇总了Golang中github.com/cloudfoundry-incubator/garden/fakes.FakeContainer类的典型用法代码示例。如果您正苦于以下问题:Golang FakeContainer类的具体用法?Golang FakeContainer怎么用?Golang FakeContainer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FakeContainer类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1:
"github.com/cloudfoundry-incubator/garden/fakes"
"github.com/cloudfoundry-incubator/garden/server/bomberman"
)
var _ = Describe("Bomberman", func() {
It("straps a bomb to the given container with the container's grace time as the countdown", func() {
detonated := make(chan garden.Container)
backend := new(fakes.FakeBackend)
backend.GraceTimeReturns(100 * time.Millisecond)
bomberman := bomberman.New(backend, func(container garden.Container) {
detonated <- container
})
container := new(fakes.FakeContainer)
container.HandleReturns("doomed")
bomberman.Strap(container)
select {
case <-detonated:
case <-time.After(backend.GraceTime(container) + 50*time.Millisecond):
Fail("did not detonate!")
}
})
Context("when the container has a grace time of 0", func() {
It("never detonates", func() {
detonated := make(chan garden.Container)
开发者ID:nagyistoce,项目名称:garden,代码行数:30,代码来源:bomberman_test.go
示例2:
})
Context("creating the connection to garden", func() {
var id Identifier
var spec ResourceTypeContainerSpec
JustBeforeEach(func() {
id = Identifier{
Name: "some-name",
}
spec = ResourceTypeContainerSpec{
Type: "some-resource-a",
}
fakeContainer := new(gfakes.FakeContainer)
fakeContainer.HandleReturns("created-handle")
worker.CreateReturns(fakeContainer, nil)
worker.LookupReturns(fakeContainer, nil)
By("connecting to the worker")
container, err := workers[0].CreateContainer(logger, id, spec)
Expect(err).NotTo(HaveOccurred())
err = container.Destroy()
Expect(err).NotTo(HaveOccurred())
By("restarting the worker with a new address")
workerServer.Stop()
开发者ID:ACPK,项目名称:atc,代码行数:30,代码来源:db_provider_test.go
示例3:
})
JustBeforeEach(func() {
createdContainer, createErr = worker.CreateContainer(logger, id, spec)
})
Context("with a resource type container spec", func() {
Context("when the resource type is supported by the worker", func() {
BeforeEach(func() {
spec = ResourceTypeContainerSpec{
Type: "some-resource",
}
})
Context("when creating the garden container works", func() {
var fakeContainer *gfakes.FakeContainer
BeforeEach(func() {
fakeContainer = new(gfakes.FakeContainer)
fakeContainer.HandleReturns("some-handle")
fakeGardenClient.CreateReturns(fakeContainer, nil)
})
It("succeeds", func() {
Expect(createErr).NotTo(HaveOccurred())
})
It("creates the container with the Garden client", func() {
Expect(fakeGardenClient.CreateCallCount()).To(Equal(1))
Expect(fakeGardenClient.CreateArgsForCall(0)).To(Equal(garden.ContainerSpec{
开发者ID:ACPK,项目名称:atc,代码行数:31,代码来源:worker_test.go
示例4:
})
Context("when getting the capacity fails", func() {
BeforeEach(func() {
serverBackend.CapacityReturns(garden.Capacity{}, errors.New("oh no!"))
})
It("returns an error", func() {
_, err := apiClient.Capacity()
Ω(err).Should(HaveOccurred())
})
})
})
Context("and the client sends a CreateRequest", func() {
var fakeContainer *fakes.FakeContainer
BeforeEach(func() {
fakeContainer = new(fakes.FakeContainer)
fakeContainer.HandleReturns("some-handle")
serverBackend.CreateReturns(fakeContainer, nil)
})
It("returns a container with the created handle", func() {
container, err := apiClient.Create(garden.ContainerSpec{
Handle: "some-handle",
})
Ω(err).ShouldNot(HaveOccurred())
Ω(container.Handle()).Should(Equal("some-handle"))
开发者ID:julz,项目名称:garden-runc,代码行数:31,代码来源:request_handling_test.go
示例5:
BeforeEach(func() {
healthcheckSpec = garden.ProcessSpec{
Path: "/bin/sh",
Args: []string{"-c", "echo", "hello"},
User: "vcap",
}
logger = lagertest.NewTestLogger("test")
gardenClient = &gardenFakes.FakeClient{}
guidGenerator := &fakeguidgen.FakeGenerator{}
guidGenerator.GuidReturns("abc-123")
gardenChecker = gardenhealth.NewChecker(rootfsPath, containerOwnerName, 0, healthcheckSpec, gardenClient, guidGenerator)
})
Describe("Healthcheck", func() {
var fakeContainer *gardenFakes.FakeContainer
var oldContainer *gardenFakes.FakeContainer
var fakeProcess *gardenFakes.FakeProcess
BeforeEach(func() {
fakeContainer = &gardenFakes.FakeContainer{}
oldContainer = &gardenFakes.FakeContainer{}
oldContainer.HandleReturns("old-guid")
fakeProcess = &gardenFakes.FakeProcess{}
})
Context("When garden is healthy", func() {
BeforeEach(func() {
gardenClient.CreateReturns(fakeContainer, nil)
gardenClient.ContainersReturns([]garden.Container{oldContainer}, nil)
fakeContainer.RunReturns(fakeProcess, nil)
开发者ID:snowsnail,项目名称:executor,代码行数:30,代码来源:checker_test.go
示例6:
})
JustBeforeEach(func() {
createdContainer, createErr = worker.CreateContainer(id, spec)
})
Context("with a resource type container spec", func() {
Context("when the resource type is supported by the worker", func() {
BeforeEach(func() {
spec = ResourceTypeContainerSpec{
Type: "some-resource",
}
})
Context("when creating works", func() {
var fakeContainer *gfakes.FakeContainer
BeforeEach(func() {
fakeContainer = new(gfakes.FakeContainer)
fakeContainer.HandleReturns("some-handle")
fakeGardenClient.CreateReturns(fakeContainer, nil)
})
It("succeeds", func() {
Ω(createErr).ShouldNot(HaveOccurred())
})
It("creates the container with the Garden client", func() {
Ω(fakeGardenClient.CreateCallCount()).Should(Equal(1))
Ω(fakeGardenClient.CreateArgsForCall(0)).Should(Equal(garden.ContainerSpec{
开发者ID:utako,项目名称:atc,代码行数:31,代码来源:worker_test.go
示例7:
Consistently(stopExited).ShouldNot(BeClosed())
close(finishCreating)
Eventually(stopExited).Should(BeClosed())
Eventually(created).Should(Receive())
err := apiClient.Ping()
Ω(err).Should(HaveOccurred())
})
})
Context("when a Run request is in-flight", func() {
It("does not wait for the request to complete", func(done Done) {
fakeContainer := new(fakes.FakeContainer)
fakeContainer.RunStub = func(spec garden.ProcessSpec, io garden.ProcessIO) (garden.Process, error) {
process := new(fakes.FakeProcess)
process.WaitStub = func() (int, error) {
time.Sleep(time.Minute)
return 0, nil
}
go func() {
defer GinkgoRecover()
_, err := io.Stdout.Write([]byte("msg 1\n"))
Ω(err).ShouldNot(HaveOccurred())
开发者ID:nagyistoce,项目名称:garden,代码行数:29,代码来源:server_test.go
注:本文中的github.com/cloudfoundry-incubator/garden/fakes.FakeContainer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论