Skip to content

Commit

Permalink
Fix missing ERROR messages and path to folder
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgenunez committed Aug 17, 2017
1 parent 8f5d9a2 commit e45fa9f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions vsphere/resource_vsphere_datacenter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func testAccCheckVSphereDatacenterDestroy(s *terraform.State) error {
return err
}
} else {
return fmt.Errorf("Datacenter '%s' still exists", path)
return fmt.Errorf("datacenter '%s' still exists", path)
}
}

Expand All @@ -92,26 +92,26 @@ func testAccCheckVSphereDatacenterExists(n string, exists bool) resource.TestChe
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[n]
if !ok {
return fmt.Errorf("[ERROR] Resource not found: %s", n)
return fmt.Errorf("resource not found: %s", n)
}

if rs.Primary.ID == "" {
return fmt.Errorf("[ERROR] No ID is set")
return fmt.Errorf("no ID is set")
}

client := testAccProvider.Meta().(*govmomi.Client)
finder := find.NewFinder(client.Client, true)

path := rs.Primary.Attributes["name"]
if _, ok := rs.Primary.Attributes["folder"]; ok {
path = rs.Primary.Attributes["folder"] + path
path = rs.Primary.Attributes["folder"] + "/" + path
}
_, err := finder.Datacenter(context.TODO(), path)
if err != nil {
switch e := err.(type) {
case *find.NotFoundError:
if exists {
return fmt.Errorf("Datacenter does not exist: %s", e.Error())
return fmt.Errorf("datacenter does not exist: %s", e.Error())
}
fmt.Printf("Expected error received: %s\n", e.Error())
return nil
Expand Down

0 comments on commit e45fa9f

Please sign in to comment.