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


Golang Container.Properties方法代码示例

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


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

示例1:

	Describe("Properties", func() {
		Context("http success", func() {
			BeforeEach(func() {
				server.AppendHandlers(
					ghttp.CombineHandlers(
						ghttp.VerifyRequest("GET", "/api/containers/containerhandle/properties"),
						ghttp.RespondWith(200, `{"Keymaster": "Gatekeeper"}`),
						func(w http.ResponseWriter, req *http.Request) {
							req.Body.Close()
						},
					),
				)
			})

			It("returns info about the container", func() {
				properties, err := container.Properties()
				Expect(err).NotTo(HaveOccurred())
				Expect(properties).Should(Equal(garden.Properties{"Keymaster": "Gatekeeper"}))
			})
		})

		Context("http 500 and returns Exception Json", func() {
			BeforeEach(func() {
				server.AppendHandlers(
					ghttp.CombineHandlers(
						ghttp.VerifyRequest("GET", "/api/containers/containerhandle/properties"),
						ghttp.RespondWith(500, `{"Message": "An exception occurred", "ExceptionMessage":"Object reference not set to an instance of an object."}`),
						func(w http.ResponseWriter, req *http.Request) {
							req.Body.Close()
						},
					),
开发者ID:stefanschneider,项目名称:garden-windows,代码行数:31,代码来源:container_test.go

示例2:

)

var _ = Describe("Container", func() {
	var (
		container       garden.Container
		propertyManager *fakes.FakePropertyManager
	)

	Describe("Properties", func() {
		BeforeEach(func() {
			propertyManager = new(fakes.FakePropertyManager)
			container = gardener.NewContainer(nil, "some-handle", nil, nil, propertyManager)
		})

		It("delegates to the property manager for Properties", func() {
			container.Properties()
			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() {
开发者ID:digideskio,项目名称:guardian,代码行数:31,代码来源:container_test.go

示例3:

			It("includes the properties", func() {
				info, err := container.Info()
				Expect(err).ToNot(HaveOccurred())

				Expect(info.Properties["foo"]).To(Equal("bar"))
				Expect(info.Properties["a"]).To(Equal("b"))

				Expect(info.Properties).To(HaveLen(2))
			})
		})

		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())
开发者ID:khassib,项目名称:garden-windows,代码行数:30,代码来源:container_info_test.go

示例4:

			It("returns the error", func() {
				_, err := container.Info()
				Ω(err).Should(Equal(disaster))
			})
		})
	})

	Describe("Properties", func() {
		Context("when getting properties succeeds", func() {
			BeforeEach(func() {
				fakeConnection.PropertiesReturns(garden.Properties{"Foo": "bar"}, nil)
			})

			It("returns the properties map", func() {
				result, err := container.Properties()
				Ω(err).ShouldNot(HaveOccurred())
				Ω(result).Should(Equal(garden.Properties{"Foo": "bar"}))
			})
		})

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

			BeforeEach(func() {
				fakeConnection.PropertiesReturns(nil, disaster)
			})

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

示例5: containerIP

func containerIP(container garden.Container) string {
	properties, err := container.Properties()
	Expect(err).NotTo(HaveOccurred())
	return properties["kawasaki.container-ip"]
}
开发者ID:digideskio,项目名称:guardian,代码行数:5,代码来源:net_test.go


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