@@ -12,7 +12,7 @@ import (
1212func TestClient_Get (t * testing.T ) {
1313
1414 c := createClient ("test-get" )
15- c . Drop ( )
15+ Flush ( c )
1616
1717 sc := NewSchema (DefaultOptions ).
1818 AddField (NewTextField ("foo" ))
@@ -72,9 +72,8 @@ func TestClient_Get(t *testing.T) {
7272}
7373
7474func TestClient_MultiGet (t * testing.T ) {
75-
7675 c := createClient ("test-get" )
77- c . Drop ( )
76+ Flush ( c )
7877
7978 sc := NewSchema (DefaultOptions ).
8079 AddField (NewTextField ("foo" ))
@@ -135,8 +134,7 @@ func TestClient_MultiGet(t *testing.T) {
135134
136135func TestClient_DictAdd (t * testing.T ) {
137136 c := createClient ("test-get" )
138- _ , err := c .pool .Get ().Do ("FLUSHALL" )
139- assert .Nil (t , err )
137+ Flush (c )
140138
141139 type fields struct {
142140 pool ConnPool
@@ -179,8 +177,7 @@ func TestClient_DictAdd(t *testing.T) {
179177func TestClient_DictDel (t * testing.T ) {
180178
181179 c := createClient ("test-get" )
182- _ , err := c .pool .Get ().Do ("FLUSHALL" )
183- assert .Nil (t , err )
180+ Flush (c )
184181
185182 terms := make ([]string , 10 )
186183 for i := 0 ; i < 10 ; i ++ {
@@ -228,8 +225,7 @@ func TestClient_DictDel(t *testing.T) {
228225
229226func TestClient_DictDump (t * testing.T ) {
230227 c := createClient ("test-get" )
231- _ , err := c .pool .Get ().Do ("FLUSHALL" )
232- assert .Nil (t , err )
228+ Flush (c )
233229
234230 terms1 := make ([]string , 10 )
235231 for i := 0 ; i < 10 ; i ++ {
@@ -279,7 +275,7 @@ func TestClient_AliasAdd(t *testing.T) {
279275 sc := NewSchema (DefaultOptions ).
280276 AddField (NewTextField ("foo" )).
281277 AddField (NewTextField ("bar" ))
282- c . Drop ( )
278+ Flush ( c )
283279 assert .Nil (t , c .CreateIndex (sc ))
284280
285281 docs := make ([]Document , 100 )
@@ -326,7 +322,7 @@ func TestClient_AliasDel(t *testing.T) {
326322 sc := NewSchema (DefaultOptions ).
327323 AddField (NewTextField ("foo" )).
328324 AddField (NewTextField ("bar" ))
329- c . Drop ( )
325+ Flush ( c )
330326 err := c .CreateIndex (sc )
331327 assert .Nil (t , err )
332328
@@ -375,13 +371,13 @@ func TestClient_AliasUpdate(t *testing.T) {
375371 sc := NewSchema (DefaultOptions ).
376372 AddField (NewTextField ("foo" )).
377373 AddField (NewTextField ("bar" ))
378- c . Drop ( )
374+ Flush ( c )
379375 err := c .CreateIndex (sc )
380376 assert .Nil (t , err )
381377
382378 docs := make ([]Document , 100 )
383379 for i := 0 ; i < 100 ; i ++ {
384- docs [i ] = NewDocument (fmt .Sprintf ("doc-alias-del -%d" , i ), 1 ).Set ("foo" , "hello world" ).Set ("bar" , "hello world foo bar baz" )
380+ docs [i ] = NewDocument (fmt .Sprintf ("doc-alias-update -%d" , i ), 1 ).Set ("foo" , "hello world" ).Set ("bar" , "hello world foo bar baz" )
385381 }
386382 err = c .Index (docs ... )
387383
@@ -418,7 +414,7 @@ func TestClient_AliasUpdate(t *testing.T) {
418414
419415func TestClient_Config (t * testing.T ) {
420416 c := createClient ("testconfigindex" )
421-
417+ Flush ( c )
422418 ret , err := c .SetConfig ("TIMEOUT" , "100" )
423419 assert .Nil (t , err )
424420 assert .Equal (t , "OK" , ret )
@@ -453,7 +449,7 @@ func TestClient_GetTagVals(t *testing.T) {
453449 AddField (NewTextField ("name" )).
454450 AddField (NewTagField ("tags" ))
455451
456- c . Drop ( )
452+ Flush ( c )
457453 c .CreateIndex (sc )
458454
459455 docs := make ([]Document , 1 )
@@ -477,7 +473,7 @@ func TestClient_SynAdd(t *testing.T) {
477473 sc := NewSchema (DefaultOptions ).
478474 AddField (NewTextField ("name" )).
479475 AddField (NewTextField ("addr" ))
480- c . Drop ( )
476+ Flush ( c )
481477 err := c .CreateIndex (sc )
482478 assert .Nil (t , err )
483479
@@ -495,7 +491,7 @@ func TestClient_SynDump(t *testing.T) {
495491 sc := NewSchema (DefaultOptions ).
496492 AddField (NewTextField ("name" )).
497493 AddField (NewTextField ("addr" ))
498- c . Drop ( )
494+ Flush ( c )
499495 err := c .CreateIndex (sc )
500496 assert .Nil (t , err )
501497
@@ -519,24 +515,28 @@ func TestClient_AddHash(t *testing.T) {
519515 sc := NewSchema (DefaultOptions ).
520516 AddField (NewTextField ("name" )).
521517 AddField (NewTextField ("addr" ))
522- c . Drop ( )
518+ Flush ( c )
523519 err := c .CreateIndex (sc )
524520 assert .Nil (t , err )
525521
526522 // Add a hash key
527523 c .pool .Get ().Do ("HMSET" , "myhash" , "field1" , "Hello" )
528524
529525 ret , err := c .AddHash ("myhash" , 1 , "english" , false )
530- assert .Nil (t , err )
531- assert .Equal (t , "OK" , ret )
526+ // Given that FT.ADDHASH is no longer valid for search2+ we assert it's error
527+ if err != nil {
528+ assert .Equal (t , "ERR unknown command `FT.ADDHASH`, with args beginning with: `testAddHash`, `myhash`, `1`, `LANGUAGE`, `english`, " , err .Error ())
529+ } else {
530+ assert .Equal (t , "OK" , ret )
531+ }
532532}
533533
534534func TestClient_AddField (t * testing.T ) {
535535 c := createClient ("alterTest" )
536536 sc := NewSchema (DefaultOptions ).
537537 AddField (NewTextField ("name" )).
538538 AddField (NewTextField ("addr" ))
539- c . Drop ( )
539+ Flush ( c )
540540 err := c .CreateIndex (sc )
541541 assert .Nil (t , err )
542542 err = c .AddField (NewNumericField ("age" ))
0 commit comments