func RandomExample() *Example {
	return &Example{
		Id:   random.Int64(1, 1000000),
		Name: random.Base64(10),
	}
}
Ejemplo n.º 2
0
			err = tr.Wait()
			Expect(err).ToNot(HaveOccurred())

			savedObj := new(Example)
			Expect(idx.GetObject(example.AlgoliaId()).Scan(savedObj)).ToNot(HaveOccurred())
			Expect(savedObj).To(Equal(example))

			example2 := RandomExample()
			bt, err := idx.BatchUpdate([]algolia.Indexable{example2})
			Expect(err).ToNot(HaveOccurred())
			Expect(example2.AlgoliaId()).To(Equal(bt.ObjectIds[0]))
		})

		It("Get object that doesn't exist", func() {
			obj := new(Example)
			err := idx.GetObject(random.Base64(10)).Scan(obj)
			Expect(err).To(HaveOccurred())
		})

		It("GetTaskStatus that doesn't exist", func() {
			ts, err := idx.GetTaskStatus(random.Int64(1, 99999999999))
			Expect(err).ToNot(HaveOccurred())
			Expect(ts.Status).To(Equal("notPublished"))
		})

		It("Can set settings", func() {
			idx.Settings().
				AttributesToIndex("name").
				AttributesForFaceting("facet_1", "facet_2").
				CustomRanking("desc(name)").
				Save()