Skip to content

Commit fc9f759

Browse files
committed
[add] dict tests require flush
1 parent fa87749 commit fc9f759

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ GOCMD=GO111MODULE=on go
44
GOBUILD=$(GOCMD) build
55
GOINSTALL=$(GOCMD) install
66
GOCLEAN=$(GOCMD) clean
7-
GOTEST=$(GOCMD) test
7+
GOTEST=$(GOCMD) test -count=1
88
GOGET=$(GOCMD) get
99
GOMOD=$(GOCMD) mod
1010

redisearch/client_test.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
1218
func TestClient_Get(t *testing.T) {
1319

1420
c := createClient("test-get")
@@ -134,7 +140,8 @@ func TestClient_MultiGet(t *testing.T) {
134140

135141
func 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

Comments
 (0)