forked from eddycjy/agollo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
file_test.go
53 lines (45 loc) 路 1.1 KB
/
file_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 (
"github.com/zouyx/agollo/test"
"os"
"testing"
)
func TestWriteConfigFile(t *testing.T) {
configPath:=""
os.Remove(getConfigFile(configPath))
jsonStr := `{
"appId": "100004458",
"cluster": "default",
"namespaceName": "application",
"configurations": {
"key1":"value1",
"key2":"value2"
},
"releaseKey": "20170430092936-dee2d58e74515ff3"
}`
config, err := createApolloConfigWithJson([]byte(jsonStr))
isNil(err)
e := writeConfigFile(config,configPath)
isNil(e)
}
func TestLoadConfigFile(t *testing.T) {
jsonStr := `{
"appId": "100004458",
"cluster": "default",
"namespaceName": "application",
"configurations": {
"key1":"value1",
"key2":"value2"
},
"releaseKey": "20170430092936-dee2d58e74515ff3"
}`
config, err := createApolloConfigWithJson([]byte(jsonStr))
isNil(err)
newConfig,e := loadConfigFile("")
t.Log(newConfig)
isNil(e)
test.Equal(t,config.AppId,newConfig.AppId)
test.Equal(t,config.ReleaseKey,newConfig.ReleaseKey)
test.Equal(t,config.Cluster,newConfig.Cluster)
test.Equal(t,config.NamespaceName,newConfig.NamespaceName)
}