本文整理汇总了Golang中github.com/cloudfoundry-incubator/garden.Container.RemoveProperty方法的典型用法代码示例。如果您正苦于以下问题:Golang Container.RemoveProperty方法的具体用法?Golang Container.RemoveProperty怎么用?Golang Container.RemoveProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry-incubator/garden.Container
的用法示例。
在下文中一共展示了Container.RemoveProperty方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
Expect(server.ReceivedRequests()).Should(HaveLen(1))
})
})
Describe("RemoveProperty", func() {
BeforeEach(func() {
server.AppendHandlers(
ghttp.CombineHandlers(
ghttp.VerifyRequest("DELETE", "/api/containers/containerhandle/properties/key"),
ghttp.RespondWith(204, ""),
),
)
})
It("makes a call out to an external service", func() {
err := container.RemoveProperty("key")
Expect(err).NotTo(HaveOccurred())
Expect(server.ReceivedRequests()).Should(HaveLen(1))
})
})
Describe("Metrics", func() {
Describe("for a valid handle", func() {
BeforeEach(func() {
server.AppendHandlers(
ghttp.CombineHandlers(
ghttp.VerifyRequest("GET", "/api/containers/containerhandle/metrics"),
ghttp.RespondWith(200, `{"MemoryStat":{"TotalUsageTowardLimit": 1234}, "DiskStat":{"TotalBytesUsed":3456,"ExclusiveBytesUsed":3456}, "CPUStat":{"Usage":5678}}`),
func(w http.ResponseWriter, req *http.Request) {
req.Body.Close()
},
示例2:
handle := propertyManager.AllArgsForCall(0)
Expect(handle).To(Equal("some-handle"))
})
It("delegates to the property manager for SetProperty", func() {
container.SetProperty("name", "value")
Expect(propertyManager.SetCallCount()).To(Equal(1))
handle, prop, val := propertyManager.SetArgsForCall(0)
Expect(handle).To(Equal("some-handle"))
Expect(prop).To(Equal("name"))
Expect(val).To(Equal("value"))
})
It("delegates to the property manager for Property", func() {
container.Property("name")
Expect(propertyManager.GetCallCount()).To(Equal(1))
handle, name := propertyManager.GetArgsForCall(0)
Expect(handle).To(Equal("some-handle"))
Expect(name).To(Equal("name"))
})
It("delegates to the property manager for RemoveProperty", func() {
container.RemoveProperty("name")
Expect(propertyManager.RemoveCallCount()).To(Equal(1))
handle, name := propertyManager.RemoveArgsForCall(0)
Expect(handle).To(Equal("some-handle"))
Expect(name).To(Equal("name"))
})
})
})
示例3:
})
It("can get a single property", func() {
err := container.SetProperty("bing", "bong")
Expect(err).NotTo(HaveOccurred())
value, err := container.Property("bing")
Expect(err).NotTo(HaveOccurred())
Expect(value).To(Equal("bong"))
})
It("can remove a single property", func() {
err := container.SetProperty("bing", "bong")
Expect(err).NotTo(HaveOccurred())
err = container.RemoveProperty("bing")
Expect(err).NotTo(HaveOccurred())
_, err = container.Property("bing")
Expect(err).To(HaveOccurred())
})
It("can filter containers based on their properties", func() {
_, err := client.Create(garden.ContainerSpec{
Properties: garden.Properties{
"somename": "wrongvalue",
},
})
Expect(err).NotTo(HaveOccurred())
containers, err := client.Containers(props)
示例4:
Expect(err).ToNot(HaveOccurred())
Expect(value).To(HaveKeyWithValue("foo", "bar"))
Expect(value).To(HaveKeyWithValue("bar", "baz"))
})
})
Describe("updating container properties", func() {
It("can CRUD", func() {
value, err := container.Property("foo")
Expect(err).ToNot(HaveOccurred())
Expect(value).To(Equal("bar"))
err = container.SetProperty("foo", "baz")
Expect(err).ToNot(HaveOccurred())
err = container.RemoveProperty("a")
Expect(err).ToNot(HaveOccurred())
info, err := container.Info()
Expect(err).ToNot(HaveOccurred())
Expect(info.Properties).To(Equal(garden.Properties{
"foo": "baz",
}))
err = container.RemoveProperty("foo")
Expect(err).ToNot(HaveOccurred())
value, err = container.Property("foo")
Expect(err).To(HaveOccurred())
Expect(err.(connection.Error).StatusCode).To(Equal(500))
示例5:
It("returns an error", func() {
err := container.SetProperty("some-property", "some-value")
Ω(err).Should(HaveOccurred())
})
})
})
Describe("removing", func() {
Context("when removing the property succeeds", func() {
BeforeEach(func() {
fakeContainer.RemovePropertyReturns(nil)
})
It("returns the property from the container", func() {
err := container.RemoveProperty("some-property")
Ω(err).ShouldNot(HaveOccurred())
Ω(fakeContainer.RemovePropertyCallCount()).Should(Equal(1))
name := fakeContainer.RemovePropertyArgsForCall(0)
Ω(name).Should(Equal("some-property"))
})
itResetsGraceTimeWhenHandling(func() {
err := container.RemoveProperty("some-property")
Ω(err).ShouldNot(HaveOccurred())
})
itFailsWhenTheContainerIsNotFound(func() error {
return container.RemoveProperty("some-property")