Skip to content

Commit

Permalink
Merge pull request #149 from yunify/fix-router-deleted-test
Browse files Browse the repository at this point in the history
Fix has been deleted test error
  • Loading branch information
runzexia authored Jan 23, 2018
2 parents 993c972 + ff66cb7 commit 33984ee
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion qingcloud/resource_qingcloud_vpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func resourceQingcloudVpcRead(d *schema.ResourceData, meta interface{}) error {
if err != nil {
return err
}
if len(output.RouterSet) == 0 {
if isRouterDeleted(output.RouterSet) {
d.SetId("")
return nil
}
Expand Down
7 changes: 7 additions & 0 deletions qingcloud/resource_qingcloud_vpc_help.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,10 @@ func waitRouterLease(d *schema.ResourceData, meta interface{}) error {
WaitForLease(output.RouterSet[0].StatusTime)
return nil
}

func isRouterDeleted(routerSet []*qc.Router) bool {
if len(routerSet) == 0 || qc.StringValue(routerSet[0].Status) == "deleted" || qc.StringValue(routerSet[0].Status) == "ceased" {
return true
}
return false
}
2 changes: 1 addition & 1 deletion qingcloud/resource_qingcloud_vpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ func testAccCheckVpcDestroyWithProvider(s *terraform.State, provider *schema.Pro
input.Routers = []*string{qc.String(rs.Primary.ID)}
output, err := client.router.DescribeRouters(input)
if err == nil {
if len(output.RouterSet) != 0 && qc.StringValue(output.RouterSet[0].Status) != "deleted" {
if !isRouterDeleted(output.RouterSet) {
return fmt.Errorf("Found Router: %s", rs.Primary.ID)
}
}
Expand Down

0 comments on commit 33984ee

Please sign in to comment.