2019-01-28 13:29:26 -05:00
|
|
|
package common
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func testAccessConfig() *AccessConfig {
|
2020-09-30 11:37:09 -04:00
|
|
|
return &AccessConfig{}
|
2019-01-28 13:29:26 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestAccessConfigPrepare_Region(t *testing.T) {
|
|
|
|
c := testAccessConfig()
|
|
|
|
|
|
|
|
c.RawRegion = "us-east-12"
|
|
|
|
err := c.ValidateRegion(c.RawRegion)
|
|
|
|
if err == nil {
|
|
|
|
t.Fatalf("should have region validation err: %s", c.RawRegion)
|
|
|
|
}
|
|
|
|
|
|
|
|
c.RawRegion = "us-east-1"
|
|
|
|
err = c.ValidateRegion(c.RawRegion)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("shouldn't have region validation err: %s", c.RawRegion)
|
|
|
|
}
|
|
|
|
|
|
|
|
c.RawRegion = "custom"
|
|
|
|
err = c.ValidateRegion(c.RawRegion)
|
|
|
|
if err == nil {
|
|
|
|
t.Fatalf("should have region validation err: %s", c.RawRegion)
|
|
|
|
}
|
|
|
|
|
|
|
|
c.RawRegion = "custom"
|
|
|
|
c.SkipValidation = true
|
|
|
|
// testing whole prepare func here; this is checking that validation is
|
|
|
|
// skipped, so we don't need a mock connection
|
|
|
|
if err := c.Prepare(nil); err != nil {
|
|
|
|
t.Fatalf("shouldn't have err: %s", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
c.SkipValidation = false
|
|
|
|
c.RawRegion = ""
|
|
|
|
if err := c.Prepare(nil); err != nil {
|
|
|
|
t.Fatalf("shouldn't have err: %s", err)
|
|
|
|
}
|
|
|
|
}
|