2018-09-24 22:35:43 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
|
|
|
|
//
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// This file is automatically generated by Magic Modules and manual
|
|
|
|
// changes will be clobbered when the file is regenerated.
|
|
|
|
//
|
|
|
|
// Please read more about how to change this file in
|
|
|
|
// .github/CONTRIBUTING.md.
|
|
|
|
//
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
package google
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/hashicorp/terraform/helper/acctest"
|
|
|
|
"github.com/hashicorp/terraform/helper/resource"
|
2018-10-26 18:03:43 +00:00
|
|
|
"github.com/hashicorp/terraform/terraform"
|
2018-09-24 22:35:43 +00:00
|
|
|
)
|
|
|
|
|
2018-11-09 21:02:03 +00:00
|
|
|
func TestAccComputeRoute_routeBasicExample(t *testing.T) {
|
2018-09-24 22:35:43 +00:00
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
resource.Test(t, resource.TestCase{
|
|
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
|
|
Providers: testAccProviders,
|
|
|
|
CheckDestroy: testAccCheckComputeRouteDestroy,
|
|
|
|
Steps: []resource.TestStep{
|
|
|
|
{
|
2018-11-09 21:02:03 +00:00
|
|
|
Config: testAccComputeRoute_routeBasicExample(acctest.RandString(10)),
|
2018-09-24 22:35:43 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
ResourceName: "google_compute_route.default",
|
|
|
|
ImportState: true,
|
|
|
|
ImportStateVerify: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2018-11-09 21:02:03 +00:00
|
|
|
func testAccComputeRoute_routeBasicExample(val string) string {
|
2018-09-24 22:35:43 +00:00
|
|
|
return fmt.Sprintf(`
|
|
|
|
resource "google_compute_route" "default" {
|
|
|
|
name = "network-route-%s"
|
|
|
|
dest_range = "15.0.0.0/24"
|
|
|
|
network = "${google_compute_network.default.name}"
|
2018-09-27 17:02:50 +00:00
|
|
|
next_hop_ip = "10.132.1.5"
|
2018-09-24 22:35:43 +00:00
|
|
|
priority = 100
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "google_compute_network" "default" {
|
|
|
|
name = "compute-network-%s"
|
|
|
|
}
|
2018-09-27 17:02:50 +00:00
|
|
|
`, val, val,
|
2018-09-24 22:35:43 +00:00
|
|
|
)
|
|
|
|
}
|
2018-10-26 18:03:43 +00:00
|
|
|
|
|
|
|
func testAccCheckComputeRouteDestroy(s *terraform.State) error {
|
|
|
|
for _, rs := range s.RootModule().Resources {
|
|
|
|
if rs.Type != "google_compute_route" {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
config := testAccProvider.Meta().(*Config)
|
|
|
|
|
|
|
|
url, err := replaceVarsForTest(rs, "https://www.googleapis.com/compute/v1/projects/{{project}}/global/routes/{{name}}")
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
_, err = sendRequest(config, "GET", url, nil)
|
|
|
|
if err == nil {
|
|
|
|
return fmt.Errorf("ComputeRoute still exists at %s", url)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|