func TestIndexerNormal(t *testing.T) {
	var err error
	var docProt *cql.DocumentWithIdx
	var ir, ir2 *Indexer
	var found bool
	initialNumDocs := 137
	ir, err = NewIndexer("/tmp/indexer_test", true, false)
	require.NoError(t, err)
	docProt = newDocProt1()
	err = ir.CreateIndex(docProt)
	require.NoError(t, err)
	docProt = newDocProt1()
	err = ir.CreateIndex(docProt)
	require.NoError(t, err)
	docProt = newDocProt2()
	err = ir.CreateIndex(docProt)
	require.NoError(t, err)
	for i := 0; i < initialNumDocs; i++ {
		doc := newDocProt1()
		doc.Doc.DocID = uint64(i)
		for j := 0; j < len(doc.Doc.UintProps); j++ {
			doc.Doc.UintProps[j].Val = uint64(i * (j + 1))
		}
		err = ir.Insert(doc)
		require.NoError(t, err)
	}
	err = ir.Close()
	require.NoError(t, err)
	ir2, err = NewIndexer("/tmp/indexer_test", false, false)
	require.NoError(t, err)
	var qr *QueryResult
	low := 30
	high := 600
	cs := &cql.CqlSelect{
		Index: "orders",
		UintPreds: map[string]cql.UintPred{
			"price": cql.UintPred{
				Name: "price",
				Low:  uint64(low),
				High: uint64(high),
			},
		},
	}
	qr, err = ir2.Select(cs)
	require.NoError(t, err)
	fmt.Println(qr.Bm.Bits())
	for i := 0; i < initialNumDocs; i++ {
		doc := newDocProt1()
		doc.Doc.DocID = uint64(i)
		for j := 0; j < len(doc.Doc.UintProps); j++ {
			doc.Doc.UintProps[j].Val = uint64(i * (j + 1))
		}
		found, err = ir2.Del(doc.Index, doc.Doc.DocID)
		require.NoError(t, err)
		require.Equal(t, true, found)
	}
	err = ir2.DestroyIndex("orders")
	require.NoError(t, err)
	err = ir2.DestroyIndex("addrs")
	require.NoError(t, err)
}
TESTCASE: normal operation sequence: new_empty, create, insert, close, new_existing, query, del, destroy
package indexer
import (
	"fmt"
	"os"
	"sync/atomic"
	"testing"
	"time"
	"github.com/pilosa/pilosa"
	"github.com/pkg/errors"
	"github.com/stretchr/testify/require"
	"github.com/deepfabric/indexer/cql"
)
func newDocProt1() *cql.DocumentWithIdx {
	return &cql.DocumentWithIdx{
		Doc: cql.Document{
			DocID: 0,
			UintProps: []*cql.UintProp{
				&cql.UintProp{
					Name:   "object",
					ValLen: 8,
					Val:    0,
				},
				&cql.UintProp{
					Name:   "price",
					ValLen: 4,
					Val:    0,
				},
				&cql.UintProp{
					Name:   "number",
					ValLen: 4,
					Val:    0,
				},
				&cql.UintProp{
					Name:   "date",
					ValLen: 8,
					Val:    0,
				},
			},
			StrProps: []*cql.StrProp{
				&cql.StrProp{
					Name: "description",
					Val:  "",
				},
				&cql.StrProp{
					Name: "note",
					Val:  "",
				},
			},
		},
		Index: "orders",
	}
}
func newDocProt2() *cql.DocumentWithIdx {
	return &cql.DocumentWithIdx{
		Doc: cql.Document{
			DocID: 0,
			UintProps: []*cql.UintProp{
				&cql.UintProp{
					Name:   "ip",
					ValLen: 4,
					Val:    0,
				},
				&cql.UintProp{
					Name:   "created",
					ValLen: 8,
					Val:    0,
				},
				&cql.UintProp{
					Name:   "updated",
					ValLen: 8,
					Val:    0,
				},
			},
			StrProps: []*cql.StrProp{
				&cql.StrProp{
					Name: "description",
					Val:  "",
				},
				&cql.StrProp{
					Name: "note",
					Val:  "",
				},
			},
		},
		Index: "addrs",
	}
}