forked from apolloconfig/agollo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomponent_common_test.go
41 lines (32 loc) · 938 Bytes
/
component_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
package agollo
import (
"testing"
"github.com/zouyx/agollo/test"
)
func TestCreateApolloConfigWithJson(t *testing.T) {
jsonStr := `{
"appId": "100004458",
"cluster": "default",
"namespaceName": "application",
"configurations": {
"key1":"value1",
"key2":"value2"
},
"releaseKey": "20170430092936-dee2d58e74515ff3"
}`
config,err:=createApolloConfigWithJson([]byte(jsonStr))
test.Nil(t,err)
test.NotNil(t,config)
test.Equal(t,"100004458",config.AppId)
test.Equal(t,"default",config.Cluster)
test.Equal(t,"application",config.NamespaceName)
test.Equal(t,"20170430092936-dee2d58e74515ff3",config.ReleaseKey)
test.Equal(t,"value1",config.Configurations["key1"])
test.Equal(t,"value2",config.Configurations["key2"])
}
func TestCreateApolloConfigWithJsonError(t *testing.T) {
jsonStr := `jklasdjflasjdfa`
config,err:=createApolloConfigWithJson([]byte(jsonStr))
test.NotNil(t,err)
test.Nil(t,config)
}