-
Notifications
You must be signed in to change notification settings - Fork 48
/
common_test.go
65 lines (58 loc) · 1 KB
/
common_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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package agollo
import (
"net/url"
"testing"
)
func TestLocalIp(t *testing.T) {
ip := getLocalIP()
if ip == "" {
t.FailNow()
}
}
func TestNotificationURL(t *testing.T) {
target := notificationURL(
&Conf{
MetaAddr: "http://127.0.0.1:8080",
AppID: "SampleApp",
Cluster: "default",
}, "")
_, err := url.Parse(target)
if err != nil {
t.Error(err)
}
}
func TestConfigURL(t *testing.T) {
target := configURL(
&Conf{
MetaAddr: "127.0.0.1:8080",
AppID: "SampleApp",
Cluster: "default",
}, "application", -1)
_, err := url.Parse(target)
if err != nil {
t.Error(err)
}
}
func TestStrIn(t *testing.T) {
cases := []struct {
slice []string
target string
ok bool
}{
{
slice: []string{"a", "b", "c"},
target: "a",
ok: true,
},
{
slice: []string{"a", "b", "c"},
target: "d",
ok: false,
},
}
for _, c := range cases {
if strIn(c.slice, c.target) != c.ok {
t.Fatal("target", c.target, "should be in slice:", c.slice, c.ok)
}
}
}