fix tests
This commit is contained in:
parent
7c3f0aa3b2
commit
d4767845f0
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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()))
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue