func TestMixedDatatypesScan_Bool(t *testing.T) { log.Printf("In TestMixedDatatypesScan_Bool()") field := "mixed_field" indexName := "index_mixeddt" bucketName := "default" e := secondaryindex.DropAllSecondaryIndexes(indexManagementAddress) FailTestIfError(e, "Error in DropAllSecondaryIndexes", t) docsToCreate := generateJSONSMixedDatatype(1000, field) seed++ log.Printf("Setting mixed datatypes JSON docs in KV") kvutility.SetKeyValues(docsToCreate, "default", "", clusterconfig.KVAddress) err := secondaryindex.CreateSecondaryIndex(indexName, bucketName, indexManagementAddress, "", []string{field}, false, nil, true, defaultIndexActiveTimeout, nil) FailTestIfError(err, "Error in creating the index", t) docScanResults := datautility.ExpectedScanResponse_bool(docs, field, true, 3) scanResults, err := secondaryindex.Range(indexName, bucketName, indexScanAddress, []interface{}{true}, []interface{}{true}, 3, true, defaultlimit, c.SessionConsistency, nil) FailTestIfError(err, "Error in scan", t) err = tv.Validate(docScanResults, scanResults) FailTestIfError(err, "Error in scan result validation", t) log.Printf("Lengths of expected and actual scan results are: %d and %d", len(docScanResults), len(scanResults)) docScanResults = datautility.ExpectedScanResponse_bool(docs, field, false, 3) scanResults, err = secondaryindex.Range(indexName, bucketName, indexScanAddress, []interface{}{false}, []interface{}{false}, 3, true, defaultlimit, c.SessionConsistency, nil) FailTestIfError(err, "Error in scan", t) err = tv.Validate(docScanResults, scanResults) FailTestIfError(err, "Error in scan result validation", t) log.Printf("Lengths of expected and actual scan results are: %d and %d", len(docScanResults), len(scanResults)) log.Printf("Length of kv docs is %d", len(docs)) }
// Test for single index field of data type bool func TestSimpleIndex_BoolDataType(t *testing.T) { log.Printf("In TestSimpleIndex_BoolDataType()") var indexName = "index_isActive" var bucketName = "default" err := secondaryindex.CreateSecondaryIndex(indexName, bucketName, indexManagementAddress, "", []string{"isActive"}, false, nil, true, defaultIndexActiveTimeout, nil) FailTestIfError(err, "Error in creating the index", t) docScanResults := datautility.ExpectedScanResponse_bool(docs, "isActive", true, 3) scanResults, err := secondaryindex.Range(indexName, bucketName, indexScanAddress, []interface{}{true}, []interface{}{true}, 3, true, defaultlimit, c.SessionConsistency, nil) FailTestIfError(err, "Error in scan", t) err = tv.Validate(docScanResults, scanResults) FailTestIfError(err, "Error in scan result validation", t) }