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


Golang Container.Property方法代码示例

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


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

示例1:

			})
		})
	})

	Describe("Property", func() {
		BeforeEach(func() {
			server.AppendHandlers(
				ghttp.CombineHandlers(
					ghttp.VerifyRequest("GET", "/api/containers/containerhandle/properties/key:val"),
					ghttp.RespondWith(200, `"a value"`),
				),
			)
		})

		It("makes a call out to an external service", func() {
			property, err := container.Property("key:val")
			Expect(err).NotTo(HaveOccurred())
			Expect(server.ReceivedRequests()).Should(HaveLen(1))

			Expect(property).Should(Equal("a value"))
		})
	})

	Describe("Stop Container", func() {
		Context("container exists", func() {
			BeforeEach(func() {
				server.AppendHandlers(
					ghttp.CombineHandlers(
						ghttp.VerifyRequest("POST", "/api/containers/containerhandle/stop"),
						ghttp.RespondWith(200, ""),
					),
开发者ID:stefanschneider,项目名称:garden-windows,代码行数:31,代码来源:container_test.go

示例2:

			Expect(propertyManager.AllCallCount()).To(Equal(1))
			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"))
		})
	})
})
开发者ID:digideskio,项目名称:guardian,代码行数:31,代码来源:container_test.go

示例3:

		})

		Describe("getting container properties without getting info", func() {
			It("can list properties", func() {
				err := container.SetProperty("bar", "baz")

				value, err := container.Properties()
				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",
				}))
开发者ID:khassib,项目名称:garden-windows,代码行数:31,代码来源:container_info_test.go

示例4:

			})
		})
	})

	Describe("Property", func() {

		propertyName := "propertyName"
		propertyValue := "propertyValue"

		Context("when getting property succeeds", func() {
			BeforeEach(func() {
				fakeConnection.PropertyReturns(propertyValue, nil)
			})

			It("returns the value", func() {
				result, err := container.Property(propertyName)
				Ω(err).ShouldNot(HaveOccurred())
				Ω(result).Should(Equal(propertyValue))
			})
		})

		Context("when getting property fails", func() {
			disaster := errors.New("oh no!")

			BeforeEach(func() {
				fakeConnection.PropertyReturns("", disaster)
			})

			It("returns the error", func() {
				_, err := container.Property(propertyName)
				Ω(err).Should(Equal(disaster))
开发者ID:guanglinlv,项目名称:garden,代码行数:31,代码来源:container_test.go

示例5:

	It("can set a single property", func() {
		err := container.SetProperty("someothername", "someothervalue")
		Expect(err).NotTo(HaveOccurred())

		properties, err := container.Properties()
		Expect(err).NotTo(HaveOccurred())
		Expect(properties).To(HaveKeyWithValue("somename", "somevalue"))
		Expect(properties).To(HaveKeyWithValue("someothername", "someothervalue"))
	})

	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())
	})
开发者ID:digideskio,项目名称:guardian,代码行数:29,代码来源:properties_test.go


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