示例#1
0
func randomTask(idx Index) *Task {
	return &Task{
		Id:    random.Int64(1, 9999999999),
		index: idx,
	}

}
func RandomExample() *Example {
	return &Example{
		Id:   random.Int64(1, 1000000),
		Name: random.Base64(10),
	}
}
			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()
		})

		It("can clear", func() {
			tr, err := idx.Clear()
			Expect(err).ToNot(HaveOccurred())