forked from Integralist/go-elasticache
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathelasticache_test.go
48 lines (37 loc) · 989 Bytes
/
elasticache_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
39
40
41
42
43
44
45
46
47
48
package elasticache
import (
"bytes"
"testing"
)
func TestParseNodes(t *testing.T) {
expectation := "localhost|127.0.0.1|11211"
cluster := `CONFIG cluster 0 25
1
localhost|127.0.0.1|11211
END`
r := bytes.NewReader([]byte(cluster))
response, _ := parseNodes(r)
if response != expectation {
t.Errorf("The response '%s' didn't match the expectation '%s'", response, expectation)
}
}
func TestParseURLs(t *testing.T) {
expectationLength := 3
response, _ := parseURLs("host|foo|1 host|bar|2 host|baz|3")
if len(response) != expectationLength {
t.Errorf("The response length '%d' didn't match the expectation '%d'", len(response), expectationLength)
}
var suite = []struct {
response string
expectation string
}{
{response[0], "foo:1"},
{response[1], "bar:2"},
{response[2], "baz:3"},
}
for _, v := range suite {
if v.response != v.expectation {
t.Errorf("The response '%s' didn't match the expectation '%s'", v.response, v.expectation)
}
}
}