Example #1
0
func (e *EtcdBaseRepository) GetAll() (*entity.EtcdBaseModels, error) {
	event, err := e.conn.Get(e.makePath(""), true, false)
	if err != nil {
		return nil, err
	}
	return entity.NewModelsFromEvent(event)
}
Example #2
0
							},
						},
					},
				},
			},
		}
		Describe("Instantiating new etcd model from etcd store event", func() {
			m1, err := entity.NewModelFromEvent(event)
			m := map[string]interface{}(*m1)
			It("should instantiate a new EtcdBaseModel successfully", func() {
				Expect(err).NotTo(HaveOccurred())
				Expect(m["App1"].(map[string]interface{})["key_1"].(map[string]interface{})["key_1_1"].(string)).To(Equal("24.00"))
				Expect(m["App1"].(map[string]interface{})["key_1"].(map[string]interface{})["key_1_2"]).To(Equal("true"))
				Expect(m["App1"].(map[string]interface{})["key_2"].(map[string]interface{})["key_2_1"]).To(Equal("Hello Hydra"))
				Expect(m["App1"].(map[string]interface{})["key_2"].(map[string]interface{})["key_2_2"]).To(Equal(""))
			})
		})
		Describe("Instantiating new etcd models (array of models) from etcd store event", func() {
			m1, err := entity.NewModelsFromEvent(event)
			m := []EtcdBaseModel(*m1)
			It("should instantiate a new EtcdBaseModel successfully", func() {
				Expect(err).NotTo(HaveOccurred())
				Expect(m[0]["key_1"].(map[string]interface{})["key_1_1"].(string)).To(Equal("24.00"))
				Expect(m[0]["key_1"].(map[string]interface{})["key_1_2"]).To(Equal("true"))
				Expect(m[1]["key_2"].(map[string]interface{})["key_2_1"]).To(Equal("Hello Hydra"))
				Expect(m[1]["key_2"].(map[string]interface{})["key_2_2"]).To(Equal(""))
			})
		})
	})
})