Exemple #1
0
	var fakeClient *fakes.Client

	BeforeEach(func() {
		fakeClient = fakes.NewClient()
	})

	Describe("Get", func() {
		It("returns a value given a valid key", func() {
			fakeClient.GetCall.Returns.Value = func(key string) string {
				if key == "some-key" {
					return "some-value"
				}
				return ""
			}

			client := etcd.NewClient(fakeClient)
			value, err := client.Get("some-key")

			Expect(err).NotTo(HaveOccurred())
			Expect(value).To(Equal("some-value"))
		})

		It("returns an error on an underlying etcd error", func() {
			fakeClient.GetCall.Returns.Error = errors.New("some etcd error")

			client := etcd.NewClient(fakeClient)
			_, err := client.Get("some-key")

			Expect(err).To(MatchError("some etcd error"))
		})
	})
Exemple #2
0
func NewEtcdClient(machines []string) etcd.Client {
	return etcd.NewClient(goetcd.NewClient(machines))
}