func initClientAndIndex(t *testing.T, name string) (c Client, i Index) {
	c = initClient(t)
	i = initIndex(t, c, name)
	return
}
initClientAndIndex is a wrapper for both the `initClient` and `initIndex`.
Please check them for more detailed informations.
package algoliasearch
import (
	"os"
	"sync"
	"testing"
)
func waitTask(t *testing.T, i Index, taskID int) {
	err := i.WaitTask(taskID)
	if err != nil {
		t.Fatalf("waitTask: Task %d not published: %s", taskID, err)
	}
}
func waitTasksAsync(t *testing.T, i Index, tasks []int) {
	var wg sync.WaitGroup
	for _, task := range tasks {
		wg.Add(1)
		go func(taskID int) {
			defer wg.Done()
			waitTask(t, i, taskID)
		}(task)
	}
	wg.Wait()
}
func addOneObject(t *testing.T, c Client, i Index) string {
	object := Object{"attribute": "value"}
	res, err := i.AddObject(object)
	if err != nil {
		t.Fatalf("addOneObject: Cannot add an object: %s", err)
	}
	waitTask(t, i, res.TaskID)
	return res.ObjectID
}
func initClient(t *testing.T) Client {
	appID := os.Getenv("ALGOLIA_APPLICATION_ID")
	apiKey := os.Getenv("ALGOLIA_API_KEY")
	if appID == "" || apiKey == "" {
		t.Fatal("initClient: Missing ALGOLIA_APPLICATION_ID and/or ALGOLIA_API_KEY")
	}
	return NewClient(appID, apiKey)
}
func initIndex(t *testing.T, c Client, name string) (i Index) {
	i = c.InitIndex(name).(*index)
	indexes, err := c.ListIndexes()
	if err != nil {
		t.Fatalf("initIndex: Cannot list existing indexes: %s", err)
	}
	for _, index := range indexes {
		if index.Name == name {
			res, err := i.Delete()
			if err != nil {
				t.Fatalf("initIndex: Cannot delete the index '%s': %s", name, err)
			}
			waitTask(t, i, res.TaskID)
		}
	}
	return
}