15
15
package main
16
16
17
17
import (
18
+ "net"
18
19
"strings"
19
20
"testing"
20
21
"time"
@@ -26,6 +27,12 @@ import (
26
27
"github.com/stretchr/testify/require"
27
28
)
28
29
30
+ type noopMap struct {}
31
+
32
+ func (* noopMap ) GetIPInfo (ip net.IP ) (ipinfo.IPInfo , error ) {
33
+ return ipinfo.IPInfo {}, nil
34
+ }
35
+
29
36
type fakeAddr string
30
37
31
38
func (a fakeAddr ) String () string { return string (a ) }
@@ -109,7 +116,7 @@ func TestIPKeyActivityPerKey(t *testing.T) {
109
116
func TestIPKeyActivityPerLocation (t * testing.T ) {
110
117
since = func (time.Time ) time.Duration { return 5 * time .Second }
111
118
reg := prometheus .NewPedanticRegistry ()
112
- ssMetrics := newPrometheusOutlineMetrics (nil , reg )
119
+ ssMetrics := newPrometheusOutlineMetrics (& noopMap {} , reg )
113
120
accessKey := "key-1"
114
121
status := "OK"
115
122
data := metrics.ProxyMetrics {}
@@ -121,7 +128,7 @@ func TestIPKeyActivityPerLocation(t *testing.T) {
121
128
expected := strings .NewReader (`
122
129
# HELP shadowsocks_ip_key_connectivity_seconds_per_location Time at least 1 connection was open for a (IP, access key) pair, per location
123
130
# TYPE shadowsocks_ip_key_connectivity_seconds_per_location counter
124
- shadowsocks_ip_key_connectivity_seconds_per_location{asn="",location=""} 5
131
+ shadowsocks_ip_key_connectivity_seconds_per_location{asn="",location="XL "} 5
125
132
` )
126
133
err := promtest .GatherAndCompare (
127
134
reg ,
0 commit comments