Exemple #1
0
func (e *EtcdBaseRepository) Get(key string) (*entity.EtcdBaseModel, error) {
	event, err := e.conn.Get(e.makePath(key), true, false)
	if err != nil {
		return nil, err
	}
	return entity.NewModelFromEvent(event)
}
Exemple #2
0
								ModifiedIndex: 12,
								CreatedIndex:  12,
							},
							&store.NodeExtern{
								Key:           "/App1/key_2/key_2_2",
								Value:         "",
								ModifiedIndex: 12,
								CreatedIndex:  12,
							},
						},
					},
				},
			},
		}
		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"))