@@ -133,6 +133,9 @@ func TestClient_BfExistsMulti(t *testing.T) {
133133func TestClient_BfInsert (t * testing.T ) {
134134 client .FlushAll ()
135135 key := "test_bf_insert"
136+ key_nocreate := "test_bf_insert_nocreate"
137+ key_noscaling := "test_bf_insert_noscaling"
138+
136139 ret , err := client .BfInsert (key , 1000 , 0.1 , - 1 , false , false , []string {"a" })
137140 assert .Nil (t , err )
138141 assert .Equal (t , 1 , len (ret ))
@@ -141,6 +144,23 @@ func TestClient_BfInsert(t *testing.T) {
141144 assert .Nil (t , err )
142145 assert .Equal (t , 1 , len (existsResult ))
143146 assert .Equal (t , int64 (1 ), existsResult [0 ])
147+
148+ ret , err = client .BfInsert (key , 1000 , 0.1 , - 1 , false , false , []string {"a" , "b" })
149+ assert .Nil (t , err )
150+ assert .Equal (t , 2 , len (ret ))
151+
152+ // Test for NOCREATE : If specified, indicates that the filter should not be created if it does not already exist
153+ _ , err = client .BfInsert (key_nocreate , 1000 , 0.1 , - 1 , true , false , []string {"a" })
154+ assert .NotNil (t , err )
155+
156+ // Test NONSCALING : Prevents the filter from creating additional sub-filters if initial capacity is reached.
157+ ret , err = client .BfInsert (key_noscaling , 2 , 0.1 , - 1 , false , true , []string {"a" , "b" })
158+ assert .Nil (t , err )
159+ assert .Equal (t , 2 , len (ret ))
160+ ret , err = client .BfInsert (key_noscaling , 2 , 0.1 , - 1 , false , true , []string {"c" })
161+ assert .NotNil (t , err )
162+ assert .Equal (t , 0 , len (ret ))
163+ assert .Equal (t , err .Error (), "ERR non scaling filter is full" )
144164}
145165
146166func TestClient_TopkReserve (t * testing.T ) {
0 commit comments