-
Notifications
You must be signed in to change notification settings - Fork 3
/
handlers_test.go
38 lines (36 loc) · 1.37 KB
/
handlers_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package main
import (
"context"
"testing"
)
func TestRedisIntegration(t *testing.T) {
client := get_redis_conn("127.0.0.1:6379", "", 0)
if urlCount := getUrlCount(context.Background(), "test", client); urlCount != "0" {
t.Error("Unexpected urlcount")
}
if count := getDomainCount(context.Background(), "test.example.com", client); count != "0" {
t.Error("Unexpected domain count")
}
if count := incUrlCount(context.Background(), "http://test.example.com/", client); count != "1" {
t.Error("Unexpected url count")
}
if urlCount := getUrlCount(context.Background(), "http://test.example.com/", client); urlCount != "1" {
t.Error("Unexpected urlcount", urlCount)
}
if urlCount := incUrlCount(context.Background(), "https://bar.example.com/foo", client); urlCount != "1" {
t.Error("Unexpected urlcount", urlCount)
}
if count := getDomainCount(context.Background(), "test.example.com", client); count != "1" {
t.Error("Unexpected domain count", count)
}
if count := getDomainCount(context.Background(), "example.com", client); count != "2" {
t.Error("Unexpected domain count", count)
}
// Note the `á` in example
if count := getDomainCount(context.Background(), "exámple.com", client); count != "0" {
t.Error("Unexpected domain count", count)
}
if count := getDomainCount(context.Background(), "", client); count != "0" {
t.Error("Unexpected domain count", count)
}
}