本文整理匯總了Golang中github.com/cloudfoundry-incubator/garden/fakes.FakeContainer.HandleReturns方法的典型用法代碼示例。如果您正苦於以下問題:Golang FakeContainer.HandleReturns方法的具體用法?Golang FakeContainer.HandleReturns怎麽用?Golang FakeContainer.HandleReturns使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cloudfoundry-incubator/garden/fakes.FakeContainer
的用法示例。
在下文中一共展示了FakeContainer.HandleReturns方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1:
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()
Eventually(func() error {
示例2:
"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)
backend := new(fakes.FakeBackend)
示例3:
})
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{
RootFSPath: "some-resource-image",
Privileged: true,
Properties: garden.Properties{},
}))
示例4:
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"))
})
It("creates the container with the spec from the request", func() {
_, err := apiClient.Create(garden.ContainerSpec{
示例5:
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)
fakeProcess.WaitReturns(0, nil)
})
It("drives a container lifecycle", func() {
err := gardenChecker.Healthcheck(logger)
By("Fetching any pre-existing healthcheck containers")
示例6:
})
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{
RootFSPath: "some-resource-image",
Privileged: true,
Properties: garden.Properties{
"concourse:type": "get",