@@ -9,6 +9,12 @@ import (
99 "github.com/stretchr/testify/assert"
1010)
1111
12+ func flush (c * Client ) (err error ) {
13+ conn := c .pool .Get ()
14+ defer conn .Close ()
15+ return conn .Send ("FLUSHALL" )
16+ }
17+
1218func TestClient_Get (t * testing.T ) {
1319
1420 c := createClient ("test-get" )
@@ -134,7 +140,8 @@ func TestClient_MultiGet(t *testing.T) {
134140
135141func TestClient_DictAdd (t * testing.T ) {
136142 c := createClient ("TestClient_DictAdd_Index" )
137- c .Drop ()
143+ // dict tests require flushall
144+ flush (c )
138145
139146 type fields struct {
140147 pool ConnPool
@@ -153,8 +160,8 @@ func TestClient_DictAdd(t *testing.T) {
153160 }{
154161 {"empty-error" , fields {pool : c .pool , name : c .name }, args {"dict1" , []string {}}, 0 , true },
155162 {"1-term" , fields {pool : c .pool , name : c .name }, args {"dict1" , []string {"term1" }}, 1 , false },
156- {"2nd-time-term" , fields {pool : c .pool , name : c .name }, args {"dict1" , []string {"term1" }}, 0 , false },
157- {"multi-term" , fields {pool : c .pool , name : c .name }, args {"dict1 " , []string {"t1" , "t2" , "t3" , "t4" , "t5" }}, 5 , false },
163+ {"2nd-time-term" , fields {pool : c .pool , name : c .name }, args {"dict1" , []string {"term1" , "term1" }}, 1 , false },
164+ {"multi-term" , fields {pool : c .pool , name : c .name }, args {"dict-multi-term " , []string {"t1" , "t2" , "t3" , "t4" , "t5" }}, 5 , false },
158165 }
159166 for _ , tt := range tests {
160167 t .Run (tt .name , func (t * testing.T ) {
@@ -170,6 +177,7 @@ func TestClient_DictAdd(t *testing.T) {
170177 if gotNewTerms != tt .wantNewTerms {
171178 t .Errorf ("DictAdd() gotNewTerms = %v, want %v" , gotNewTerms , tt .wantNewTerms )
172179 }
180+ i .DictDel (tt .args .dictionaryName , tt .args .terms )
173181 })
174182 }
175183}
0 commit comments