Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests are failing when actual redis server is used #57

Open
yashmehrotra opened this issue Mar 23, 2021 · 0 comments
Open

Tests are failing when actual redis server is used #57

yashmehrotra opened this issue Mar 23, 2021 · 0 comments

Comments

@yashmehrotra
Copy link

yashmehrotra commented Mar 23, 2021

I was porting this module to get it working with github.com/gomodule/redigo. After running the tests, a few of them were failing. It was surprising since I did not change any logical code.

I then ran these tests with a live redis server instead and noticed that the same tests are failing.

Here is the diff if you want to test this yourself

 func rateLimiter() *redis_rate.Limiter {
-	ring := redis.NewRing(&redis.RingOptions{
-		Addrs: map[string]string{"server0": ":6379"},
-	})
-	if err := ring.FlushDB(context.TODO()).Err(); err != nil {
-		panic(err)
-	}
-	return redis_rate.NewLimiter(ring)
+	client := redis.NewClient(&redis.Options{Addr: "localhost:6379"})
+	return redis_rate.NewLimiter(client)
 }
 
 func TestAllow(t *testing.T) {

The below tests are failing:

go test ./...
--- FAIL: TestAllowN_IncrementZero (0.00s)
    rate_test.go:82: 
        	Error Trace:	rate_test.go:82
        	Error:      	Not equal: 
        	            	expected: 0
        	            	actual  : 10
        	Test:       	TestAllowN_IncrementZero
--- FAIL: TestRetryAfter (0.00s)
    assertion_compare.go:240: 
        	Error Trace:	rate_test.go:121
        	Error:      	"998632997" is not less than or equal to "1000000"
        	Test:       	TestRetryAfter
        	Messages:   	[]
--- FAIL: TestAllowAtMost (0.00s)
    rate_test.go:133: 
        	Error Trace:	rate_test.go:133
        	Error:      	Not equal: 
        	            	expected: 0
        	            	actual  : 1
        	Test:       	TestAllowAtMost
--- FAIL: TestAllowAtMost_IncrementZero (0.00s)
    rate_test.go:190: 
        	Error Trace:	rate_test.go:190
        	Error:      	Not equal: 
        	            	expected: 0
        	            	actual  : 10
        	Test:       	TestAllowAtMost_IncrementZero
FAIL
FAIL	github.com/go-redis/redis_rate/v9	0.007s
FAIL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant