2017-03-03 03:56:17 -05:00
|
|
|
package ecs
|
|
|
|
|
|
|
|
import (
|
2019-04-25 22:37:49 -04:00
|
|
|
"os"
|
2017-03-03 03:56:17 -05:00
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func testAlicloudAccessConfig() *AlicloudAccessConfig {
|
|
|
|
return &AlicloudAccessConfig{
|
2017-03-03 04:56:48 -05:00
|
|
|
AlicloudAccessKey: "ak",
|
|
|
|
AlicloudSecretKey: "acs",
|
2017-03-03 03:56:17 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestAlicloudAccessConfigPrepareRegion(t *testing.T) {
|
|
|
|
c := testAlicloudAccessConfig()
|
|
|
|
|
2019-04-25 22:37:49 -04:00
|
|
|
c.AlicloudRegion = ""
|
2017-03-03 03:56:17 -05:00
|
|
|
if err := c.Prepare(nil); err == nil {
|
2019-04-25 22:37:49 -04:00
|
|
|
t.Fatalf("should have err")
|
2017-03-03 03:56:17 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
c.AlicloudRegion = "cn-beijing"
|
|
|
|
if err := c.Prepare(nil); err != nil {
|
|
|
|
t.Fatalf("shouldn't have err: %s", err)
|
|
|
|
}
|
|
|
|
|
2019-04-25 22:37:49 -04:00
|
|
|
os.Setenv("ALICLOUD_REGION", "cn-hangzhou")
|
|
|
|
c.AlicloudRegion = ""
|
2017-03-03 03:56:17 -05:00
|
|
|
if err := c.Prepare(nil); err != nil {
|
|
|
|
t.Fatalf("shouldn't have err: %s", err)
|
|
|
|
}
|
|
|
|
|
2019-04-25 22:37:49 -04:00
|
|
|
c.AlicloudSkipValidation = false
|
2017-03-03 03:56:17 -05:00
|
|
|
}
|