forked from apolloconfig/agollo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
request_test.go
53 lines (43 loc) · 1.14 KB
/
request_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
package agollo
import (
"testing"
"time"
"github.com/zouyx/agollo/test"
)
func TestRequestRecovery(t *testing.T) {
time.Sleep(1*time.Second)
mockIpList(t)
go runMockConfigBackupServer(normalBackupConfigResponse)
defer closeAllMockServicesServer()
appConfig:=GetAppConfig()
urlSuffix:=getConfigUrlSuffix(appConfig)
o,err:=requestRecovery(appConfig,urlSuffix,autoSyncConfigServicesSuccessCallBack)
test.Nil(t,err)
test.Nil(t,o)
}
//func TestErrorRequestRecovery(t *testing.T) {
// time.Sleep(1*time.Second)
// mockBackupConfig()
// go runMockConfigBackupServer(errorBackupConfigResponse)
// defer closeAllMockServicesServer()
//
// appConfig:=GetAppConfig()
// urlSuffix:=getConfigUrlSuffix(appConfig)
//
// o,err:=requestRecovery(appConfig,urlSuffix,autoSyncConfigServicesSuccessCallBack)
//
// test.NotNil(t,err)
// test.Nil(t,o)
//}
//
//func mockBackupConfig(){
// syncServerIpListSuccessCallBack([]byte(servicesResponseStr))
//}
func mockIpList(t *testing.T) {
go runMockServicesServer(normalServicesResponse)
defer closeMockServicesServer()
time.Sleep(1*time.Second)
err:=syncServerIpList()
test.Nil(t,err)
test.Equal(t,2,len(servers))
}