forked from weibocom/motan-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathha_test.go
40 lines (35 loc) · 909 Bytes
/
ha_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
package ha
import (
"testing"
motan "github.com/weibocom/motan-go/core"
)
func NewFailOver(url *motan.URL) motan.HaStrategy {
return &FailOverHA{url: url}
}
func TestGetHa(t *testing.T) {
defaultExtFactory := &motan.DefaultExtensionFactory{}
defaultExtFactory.Initialize()
RegistDefaultHa(defaultExtFactory)
p := make(map[string]string)
p[motan.Hakey] = FailOver
url := &motan.URL{Parameters: p}
ha := defaultExtFactory.GetHa(url)
if ha.GetName() != "failover" {
t.Error("GetHa name Error")
}
getURL := ha.GetURL()
if url.GetIdentity() != getURL.GetIdentity() {
t.Error("GetURL Error")
}
p[motan.Hakey] = BackupRequest
p[motan.FilterKey] = ""
url = &motan.URL{Parameters: p}
ha = defaultExtFactory.GetHa(url)
if ha.GetName() != "backupRequest" {
t.Error("GetHa name Error")
}
getURL = ha.GetURL()
if url.GetIdentity() != getURL.GetIdentity() {
t.Error("GetURL Error")
}
}