Ejemplo n.º 1
0
				Expect(err).NotTo(HaveOccurred())

				response, err := etcdClient.Get(`/routes/post_here,1.2.3.4:7000`, false, false)
				Expect(err).NotTo(HaveOccurred())
				Expect(response.Node.TTL).To(Equal(int64(50)))
				Expect(response.Node.Value).To(MatchJSON(`{
						"ip": "1.2.3.4",
						"route": "post_here",
						"port": 7000,
						"ttl": 50,
						"log_guid": "my-guid"
					}`))
			})

			It("Returns the ETCD error if bad inputs are given", func() {
				route.TTL = -1
				err := etcd.SaveRoute(route)
				Expect(err).To(HaveOccurred())
			})

			Context("when an entry already exists", func() {
				BeforeEach(func() {
					route.Route = "next-route"
					route.IP = "9.8.7.6"
					route.Port = 12345

					err := etcd.SaveRoute(route)
					Expect(err).NotTo(HaveOccurred())
				})

				It("Updates a route if one already exists", func() {
Ejemplo n.º 2
0
						}`))
					})
				})

				Context("when an entry already exists", func() {
					BeforeEach(func() {
						route.Route = "next-route"
						route.IP = "9.8.7.6"
						route.Port = 12345

						err := etcd.SaveRoute(route)
						Expect(err).NotTo(HaveOccurred())
					})

					It("Updates a route if one already exists", func() {
						route.TTL = 47
						route.LogGuid = "new-guid"

						err := etcd.SaveRoute(route)
						Expect(err).NotTo(HaveOccurred())

						node, err := etcdClient.Get(`/routes/next-route,9.8.7.6:12345`)
						Expect(err).NotTo(HaveOccurred())
						Expect(node.TTL).To(Equal(uint64(47)))
						Expect(node.Value).To(MatchJSON(`{
							"ip": "9.8.7.6",
							"route": "next-route",
							"port": 12345,
							"ttl": 47,
							"log_guid": "new-guid"
						}`))