@@ -59,7 +59,7 @@ func TestConfiguration(t *testing.T) {
5959 p , ok := cf .GetProfile ("hh" )
6060 assert .False (t , ok )
6161 assert .Equal (t , Profile {Name : "hh" }, p )
62- p , ok = cf .GetProfile ("default" )
62+ p , _ = cf .GetProfile ("default" )
6363 assert .Equal (t , Profile {Name : "default" , Mode : "" , OutputFormat : "json" , Language : "en" }, p )
6464
6565 //PutProfile
@@ -114,7 +114,7 @@ func TestLoadProfile(t *testing.T) {
114114 }()
115115 hookLoadConfiguration = func (fn func (path string ) (* Configuration , error )) func (path string ) (* Configuration , error ) {
116116 return func (path string ) (* Configuration , error ) {
117- return & Configuration {CurrentProfile : "default" , Profiles : []Profile {Profile {Name : "default" , Mode : AK , AccessKeyId : "default_aliyun_access_key_id" , AccessKeySecret : "default_aliyun_access_key_secret" , OutputFormat : "json" }, Profile {Name : "aaa" , Mode : AK , AccessKeyId : "sdf" , AccessKeySecret : "ddf" , OutputFormat : "json" }}}, nil
117+ return & Configuration {CurrentProfile : "default" , Profiles : []Profile {{Name : "default" , Mode : AK , AccessKeyId : "default_aliyun_access_key_id" , AccessKeySecret : "default_aliyun_access_key_secret" , OutputFormat : "json" }, {Name : "aaa" , Mode : AK , AccessKeyId : "sdf" , AccessKeySecret : "ddf" , OutputFormat : "json" }}}, nil
118118 }
119119 }
120120 //testcase 1
@@ -198,7 +198,7 @@ func TestNewConfigFromBytes(t *testing.T) {
198198
199199 conf , err := NewConfigFromBytes ([]byte (bytesConf ))
200200 assert .Nil (t , err )
201- assert .Equal (t , & Configuration {Profiles : []Profile {Profile {Language : "en" , Name : "default" , Mode : "AK" , AccessKeyId : "access_key_id" , AccessKeySecret : "access_key_secret" , RegionId : "cn-hangzhou" , OutputFormat : "json" }}}, conf )
201+ assert .Equal (t , & Configuration {Profiles : []Profile {{Language : "en" , Name : "default" , Mode : "AK" , AccessKeyId : "access_key_id" , AccessKeySecret : "access_key_secret" , RegionId : "cn-hangzhou" , OutputFormat : "json" }}}, conf )
202202}
203203
204204func TestSaveConfiguration (t * testing.T ) {
@@ -212,7 +212,7 @@ func TestSaveConfiguration(t *testing.T) {
212212 return "."
213213 }
214214 }
215- conf := & Configuration {Profiles : []Profile {Profile {Language : "en" , Name : "default" , Mode : "AK" , AccessKeyId : "access_key_id" , AccessKeySecret : "access_key_secret" , RegionId : "cn-hangzhou" , OutputFormat : "json" }}}
215+ conf := & Configuration {Profiles : []Profile {{Language : "en" , Name : "default" , Mode : "AK" , AccessKeyId : "access_key_id" , AccessKeySecret : "access_key_secret" , RegionId : "cn-hangzhou" , OutputFormat : "json" }}}
216216 bytes , err := json .MarshalIndent (conf , "" , "\t " )
217217 assert .Nil (t , err )
218218 err = SaveConfiguration (conf )
@@ -242,15 +242,15 @@ func TestLoadConfiguration(t *testing.T) {
242242 //testcase 1
243243 cf , err := LoadConfiguration (GetConfigPath () + "/" + configFile )
244244 assert .Nil (t , err )
245- assert .Equal (t , & Configuration {CurrentProfile : "default" , Profiles : []Profile {Profile {Name : "default" , Mode : "" , OutputFormat : "json" , Language : "en" }}}, cf )
246- conf := & Configuration {Profiles : []Profile {Profile {Language : "en" , Name : "default" , Mode : "AK" , AccessKeyId : "access_key_id" , AccessKeySecret : "access_key_secret" , RegionId : "cn-hangzhou" , OutputFormat : "json" }}}
245+ assert .Equal (t , & Configuration {CurrentProfile : "default" , Profiles : []Profile {{Name : "default" , Mode : "" , OutputFormat : "json" , Language : "en" }}}, cf )
246+ conf := & Configuration {Profiles : []Profile {{Language : "en" , Name : "default" , Mode : "AK" , AccessKeyId : "access_key_id" , AccessKeySecret : "access_key_secret" , RegionId : "cn-hangzhou" , OutputFormat : "json" }}}
247247 err = SaveConfiguration (conf )
248248 assert .Nil (t , err )
249249
250250 //testcase 2
251251 w .Reset ()
252252 cf , err = LoadConfiguration (GetConfigPath () + "/" + configFile )
253- assert .Equal (t , & Configuration {CurrentProfile : "" , Profiles : []Profile {Profile {Name : "default" , Mode : "AK" , AccessKeyId : "access_key_id" , AccessKeySecret : "access_key_secret" , RegionId : "cn-hangzhou" , OutputFormat : "json" , Language : "en" }}}, cf )
253+ assert .Equal (t , & Configuration {CurrentProfile : "" , Profiles : []Profile {{Name : "default" , Mode : "AK" , AccessKeyId : "access_key_id" , AccessKeySecret : "access_key_secret" , RegionId : "cn-hangzhou" , OutputFormat : "json" , Language : "en" }}}, cf )
254254 assert .Nil (t , err )
255255
256256}
@@ -262,7 +262,7 @@ func TestLoadProfileWithContext(t *testing.T) {
262262 }()
263263 hookLoadConfiguration = func (fn func (path string ) (* Configuration , error )) func (path string ) (* Configuration , error ) {
264264 return func (path string ) (* Configuration , error ) {
265- return & Configuration {CurrentProfile : "default" , Profiles : []Profile {Profile {Name : "default" , Mode : AK , AccessKeyId : "default_aliyun_access_key_id" , AccessKeySecret : "default_aliyun_access_key_secret" , OutputFormat : "json" }, Profile {Name : "aaa" , Mode : AK , AccessKeyId : "sdf" , AccessKeySecret : "ddf" , OutputFormat : "json" }}}, nil
265+ return & Configuration {CurrentProfile : "default" , Profiles : []Profile {{Name : "default" , Mode : AK , AccessKeyId : "default_aliyun_access_key_id" , AccessKeySecret : "default_aliyun_access_key_secret" , OutputFormat : "json" }, {Name : "aaa" , Mode : AK , AccessKeyId : "sdf" , AccessKeySecret : "ddf" , OutputFormat : "json" }}}, nil
266266 }
267267 }
268268 w := new (bytes.Buffer )
0 commit comments