@@ -19,8 +19,6 @@ func (e EListener) Event(event *event.Event) {
19
19
openlog .Info (fmt .Sprintf ("config value after change %s |%s" , event .Key , event .Value ))
20
20
}
21
21
22
- var filename2 string
23
-
24
22
func TestInit (t * testing.T ) {
25
23
f1Bytes := []byte (`
26
24
age: 14
@@ -33,7 +31,7 @@ exist: true
33
31
` )
34
32
d , _ := os .Getwd ()
35
33
filename1 := filepath .Join (d , "f1.yaml" )
36
- filename2 = filepath .Join (d , "f2.yaml" )
34
+ filename2 : = filepath .Join (d , "f2.yaml" )
37
35
f1 , err := os .Create (filename1 )
38
36
assert .NoError (t , err )
39
37
defer f1 .Close ()
@@ -116,6 +114,25 @@ func TestConfig_RegisterListener(t *testing.T) {
116
114
117
115
}
118
116
117
+ func TestConfig_Update (t * testing.T ) {
118
+ t .Run ("update a simple type config" , func (t * testing.T ) {
119
+ assert .NoError (t , archaius .Set ("aNumber" , 1 ))
120
+ assert .NoError (t , archaius .Set ("aNumber" , 2 ))
121
+ })
122
+ t .Run ("update a slice config" , func (t * testing.T ) {
123
+ assert .NoError (t , archaius .Set ("aSlice" , []int {1 ,2 ,3 }))
124
+ assert .NoError (t , archaius .Set ("aSlice" , []int {1 ,2 ,3 }))
125
+ assert .NoError (t , archaius .Set ("aSlice" , 1 ))
126
+ assert .NoError (t , archaius .Set ("aSlice" , []int {1 ,2 ,3 }))
127
+ })
128
+ t .Run ("update a map config" , func (t * testing.T ) {
129
+ assert .NoError (t , archaius .Set ("aMap" , map [int ]int {1 : 1 }))
130
+ assert .NoError (t , archaius .Set ("aMap" , map [int ]int {1 : 1 }))
131
+ assert .NoError (t , archaius .Set ("aMap" , 1 ))
132
+ assert .NoError (t , archaius .Set ("aMap" , map [int ]int {1 : 1 }))
133
+ })
134
+ }
135
+
119
136
func TestUnmarshalConfig (t * testing.T ) {
120
137
b := []byte (`
121
138
key: peter
0 commit comments