@@ -21,6 +21,7 @@ import (
2121
2222 "github.com/casbin/casbin/v2"
2323 "github.com/casbin/casbin/v2/util"
24+ "github.com/gomodule/redigo/redis"
2425)
2526
2627func testGetPolicy (t * testing.T , e * casbin.Enforcer , res [][]string ) {
@@ -356,7 +357,7 @@ func TestAdapters(t *testing.T) {
356357 a , _ := NewAdapter ("tcp" , "127.0.0.1:6379" )
357358
358359 // Use the following if Redis has password like "123"
359- //a, err := NewAdapterWithPassword("tcp", "127.0.0.1:6379", "123")
360+ // a, err := NewAdapterWithPassword("tcp", "127.0.0.1:6379", "123")
360361
361362 // Use the following if you use Redis with a account
362363 // a, err := NewAdapterWithUser("tcp", "127.0.0.1:6379", "testaccount", "userpass")
@@ -369,3 +370,22 @@ func TestAdapters(t *testing.T) {
369370 testUpdatePolicies (t , a )
370371 testUpdateFilteredPolicies (t , a )
371372}
373+
374+ func TestPoolAdapters (t * testing.T ) {
375+ a , err := NewAdapterWithPool (& redis.Pool {
376+ Dial : func () (redis.Conn , error ) {
377+ return redis .Dial ("tcp" , "127.0.0.1:6379" )
378+ },
379+ })
380+ if err != nil {
381+ t .Fatal (err )
382+ }
383+
384+ testSaveLoad (t , a )
385+ testAutoSave (t , a )
386+ testFilteredPolicy (t , a )
387+ testAddPolicies (t , a )
388+ testRemovePolicies (t , a )
389+ testUpdatePolicies (t , a )
390+ testUpdateFilteredPolicies (t , a )
391+ }
0 commit comments