mirror of
https://github.com/opentofu/opentofu.git
synced 2025-01-07 14:44:11 -06:00
0769674c54
Most resources are commented out at this stage, as they require surgery to make them work with the new world of the Azure SDK.
160 lines
4.2 KiB
Go
160 lines
4.2 KiB
Go
package azurerm
|
|
|
|
//import (
|
|
// "fmt"
|
|
// "net/http"
|
|
// "testing"
|
|
//
|
|
// "github.com/hashicorp/terraform/helper/acctest"
|
|
// "github.com/hashicorp/terraform/helper/resource"
|
|
// "github.com/hashicorp/terraform/terraform"
|
|
//)
|
|
//
|
|
//func TestAccAzureRMRoute_basic(t *testing.T) {
|
|
//
|
|
// ri := acctest.RandInt()
|
|
// config := fmt.Sprintf(testAccAzureRMRoute_basic, ri, ri, ri)
|
|
//
|
|
// resource.Test(t, resource.TestCase{
|
|
// PreCheck: func() { testAccPreCheck(t) },
|
|
// Providers: testAccProviders,
|
|
// CheckDestroy: testCheckAzureRMRouteDestroy,
|
|
// Steps: []resource.TestStep{
|
|
// resource.TestStep{
|
|
// Config: config,
|
|
// Check: resource.ComposeTestCheckFunc(
|
|
// testCheckAzureRMRouteExists("azurerm_route.test"),
|
|
// ),
|
|
// },
|
|
// },
|
|
// })
|
|
//}
|
|
//
|
|
//func TestAccAzureRMRoute_multipleRoutes(t *testing.T) {
|
|
//
|
|
// ri := acctest.RandInt()
|
|
// preConfig := fmt.Sprintf(testAccAzureRMRoute_basic, ri, ri, ri)
|
|
// postConfig := fmt.Sprintf(testAccAzureRMRoute_multipleRoutes, ri, ri, ri)
|
|
//
|
|
// resource.Test(t, resource.TestCase{
|
|
// PreCheck: func() { testAccPreCheck(t) },
|
|
// Providers: testAccProviders,
|
|
// CheckDestroy: testCheckAzureRMRouteDestroy,
|
|
// Steps: []resource.TestStep{
|
|
// resource.TestStep{
|
|
// Config: preConfig,
|
|
// Check: resource.ComposeTestCheckFunc(
|
|
// testCheckAzureRMRouteExists("azurerm_route.test"),
|
|
// ),
|
|
// },
|
|
//
|
|
// resource.TestStep{
|
|
// Config: postConfig,
|
|
// Check: resource.ComposeTestCheckFunc(
|
|
// testCheckAzureRMRouteExists("azurerm_route.test1"),
|
|
// ),
|
|
// },
|
|
// },
|
|
// })
|
|
//}
|
|
//
|
|
//func testCheckAzureRMRouteExists(name string) resource.TestCheckFunc {
|
|
// return func(s *terraform.State) error {
|
|
//
|
|
// rs, ok := s.RootModule().Resources[name]
|
|
// if !ok {
|
|
// return fmt.Errorf("Not found: %s", name)
|
|
// }
|
|
//
|
|
// name := rs.Primary.Attributes["name"]
|
|
// rtName := rs.Primary.Attributes["route_table_name"]
|
|
// resourceGroup, hasResourceGroup := rs.Primary.Attributes["resource_group_name"]
|
|
// if !hasResourceGroup {
|
|
// return fmt.Errorf("Bad: no resource group found in state for route: %s", name)
|
|
// }
|
|
//
|
|
// conn := testAccProvider.Meta().(*ArmClient).routesClient
|
|
//
|
|
// resp, err := conn.Get(resourceGroup, rtName, name)
|
|
// if err != nil {
|
|
// return fmt.Errorf("Bad: Get on routesClient: %s", err)
|
|
// }
|
|
//
|
|
// if resp.StatusCode == http.StatusNotFound {
|
|
// return fmt.Errorf("Bad: Route %q (resource group: %q) does not exist", name, resourceGroup)
|
|
// }
|
|
//
|
|
// return nil
|
|
// }
|
|
//}
|
|
//
|
|
//func testCheckAzureRMRouteDestroy(s *terraform.State) error {
|
|
// conn := testAccProvider.Meta().(*ArmClient).routesClient
|
|
//
|
|
// for _, rs := range s.RootModule().Resources {
|
|
// if rs.Type != "azurerm_route" {
|
|
// continue
|
|
// }
|
|
//
|
|
// name := rs.Primary.Attributes["name"]
|
|
// rtName := rs.Primary.Attributes["route_table_name"]
|
|
// resourceGroup := rs.Primary.Attributes["resource_group_name"]
|
|
//
|
|
// resp, err := conn.Get(resourceGroup, rtName, name)
|
|
//
|
|
// if err != nil {
|
|
// return nil
|
|
// }
|
|
//
|
|
// if resp.StatusCode != http.StatusNotFound {
|
|
// return fmt.Errorf("Route still exists:\n%#v", resp.Properties)
|
|
// }
|
|
// }
|
|
//
|
|
// return nil
|
|
//}
|
|
//
|
|
//var testAccAzureRMRoute_basic = `
|
|
//resource "azurerm_resource_group" "test" {
|
|
// name = "acctestrg-%d"
|
|
// location = "West US"
|
|
//}
|
|
//
|
|
//resource "azurerm_route_table" "test" {
|
|
// name = "acctestrt%d"
|
|
// location = "West US"
|
|
// resource_group_name = "${azurerm_resource_group.test.name}"
|
|
//}
|
|
//
|
|
//resource "azurerm_route" "test" {
|
|
// name = "acctestroute%d"
|
|
// resource_group_name = "${azurerm_resource_group.test.name}"
|
|
// route_table_name = "${azurerm_route_table.test.name}"
|
|
//
|
|
// address_prefix = "10.1.0.0/16"
|
|
// next_hop_type = "vnetlocal"
|
|
//}
|
|
//`
|
|
//
|
|
//var testAccAzureRMRoute_multipleRoutes = `
|
|
//resource "azurerm_resource_group" "test" {
|
|
// name = "acctestrg-%d"
|
|
// location = "West US"
|
|
//}
|
|
//
|
|
//resource "azurerm_route_table" "test" {
|
|
// name = "acctestrt%d"
|
|
// location = "West US"
|
|
// resource_group_name = "${azurerm_resource_group.test.name}"
|
|
//}
|
|
//
|
|
//resource "azurerm_route" "test1" {
|
|
// name = "acctestroute%d"
|
|
// resource_group_name = "${azurerm_resource_group.test.name}"
|
|
// route_table_name = "${azurerm_route_table.test.name}"
|
|
//
|
|
// address_prefix = "10.2.0.0/16"
|
|
// next_hop_type = "none"
|
|
//}
|
|
//`
|