fix tests

This commit is contained in:
Megan Marsh 2018-10-16 15:01:13 -07:00
parent 7c3f0aa3b2
commit d4767845f0
3 changed files with 8 additions and 5 deletions

View File

@ -17,19 +17,19 @@ func TestAccessConfigPrepare_Region(t *testing.T) {
mockConn := &mockEC2Client{}
c.RawRegion = "us-east-12"
valid := ValidateRegion(c.RawRegion, mockConn)
valid, _ := ValidateRegion(c.RawRegion, mockConn)
if valid {
t.Fatalf("should have region validation err: %s", c.RawRegion)
}
c.RawRegion = "us-east-1"
valid = ValidateRegion(c.RawRegion, mockConn)
valid, _ = ValidateRegion(c.RawRegion, mockConn)
if !valid {
t.Fatalf("shouldn't have region validation err: %s", c.RawRegion)
}
c.RawRegion = "custom"
valid = ValidateRegion(c.RawRegion, mockConn)
valid, _ = ValidateRegion(c.RawRegion, mockConn)
if valid {
t.Fatalf("should have region validation err: %s", c.RawRegion)
}

View File

@ -112,7 +112,6 @@ func (c *AMIConfig) prepareRegions(ec2conn ec2iface.EC2API, accessConfig *Access
if !c.AMISkipRegionValidation {
// Verify the region is real
ec2conn := getValidationSession()
valid, err := ValidateRegion(region, ec2conn)
if err != nil {
errs = append(errs, fmt.Errorf("error validating region: %s", err.Error()))

View File

@ -55,13 +55,17 @@ func TestAMIConfigPrepare_regions(t *testing.T) {
c.AMISkipRegionValidation = true
var errs []error
var err error
mockConn := &mockEC2Client{}
if errs = c.prepareRegions(mockConn, nil, errs); len(errs) > 0 {
t.Fatalf("shouldn't have err: %#v", errs)
}
c.AMISkipRegionValidation = false
c.AMIRegions = listEC2Regions(mockConn)
c.AMIRegions, err = listEC2Regions(mockConn)
if err != nil {
t.Fatalf("shouldn't have err: %s", err.Error())
}
if errs = c.prepareRegions(mockConn, nil, errs); len(errs) > 0 {
t.Fatalf("shouldn't have err: %#v", errs)
}