Import support for Image Lists
This commit is contained in:
parent
76b224ea0a
commit
18dc5559ba
|
@ -0,0 +1,33 @@
|
|||
package opc
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/acctest"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
)
|
||||
|
||||
func TestAccOPCIPNetwork_importBasic(t *testing.T) {
|
||||
resourceName := "opc_compute_ip_network.test"
|
||||
|
||||
rInt := acctest.RandInt()
|
||||
config := testAccOPCIPNetworkConfig_Basic(rInt)
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() {
|
||||
testAccPreCheck(t)
|
||||
},
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: opcResourceCheck(resourceName, testAccOPCCheckIPNetworkDestroyed),
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: config,
|
||||
},
|
||||
{
|
||||
ResourceName: resourceName,
|
||||
ImportState: true,
|
||||
ImportStateVerify: true,
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
|
@ -13,6 +13,9 @@ func resourceOPCIPNetwork() *schema.Resource {
|
|||
Read: resourceOPCIPNetworkRead,
|
||||
Update: resourceOPCIPNetworkUpdate,
|
||||
Delete: resourceOPCIPNetworkDelete,
|
||||
Importer: &schema.ResourceImporter{
|
||||
State: schema.ImportStatePassthrough,
|
||||
},
|
||||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"name": {
|
||||
|
|
|
@ -12,7 +12,31 @@ import (
|
|||
|
||||
func TestAccOPCIPNetwork_Basic(t *testing.T) {
|
||||
rInt := acctest.RandInt()
|
||||
resName := "opc_compute_ip_network.foo"
|
||||
resName := "opc_compute_ip_network.test"
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: opcResourceCheck(resName, testAccOPCCheckIPNetworkDestroyed),
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: testAccOPCIPNetworkConfig_Basic(rInt),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
opcResourceCheck(resName, testAccOPCCheckIPNetworkExists),
|
||||
resource.TestCheckResourceAttr(resName, "ip_address_prefix", "10.0.12.0/24"),
|
||||
resource.TestCheckResourceAttr(resName, "public_napt_enabled", "false"),
|
||||
resource.TestCheckResourceAttr(resName, "description", fmt.Sprintf("testing-desc-%d", rInt)),
|
||||
resource.TestCheckResourceAttr(resName, "name", fmt.Sprintf("testing-ip-network-%d", rInt)),
|
||||
resource.TestMatchResourceAttr(resName, "uri", regexp.MustCompile("testing-ip-network")),
|
||||
),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestAccOPCIPNetwork_Update(t *testing.T) {
|
||||
rInt := acctest.RandInt()
|
||||
resName := "opc_compute_ip_network.test"
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
|
@ -46,7 +70,7 @@ func TestAccOPCIPNetwork_Basic(t *testing.T) {
|
|||
|
||||
func testAccOPCIPNetworkConfig_Basic(rInt int) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "opc_compute_ip_network" "foo" {
|
||||
resource "opc_compute_ip_network" "test" {
|
||||
name = "testing-ip-network-%d"
|
||||
description = "testing-desc-%d"
|
||||
ip_address_prefix = "10.0.12.0/24"
|
||||
|
@ -55,7 +79,7 @@ resource "opc_compute_ip_network" "foo" {
|
|||
|
||||
func testAccOPCIPNetworkConfig_BasicUpdate(rInt int) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "opc_compute_ip_network" "foo" {
|
||||
resource "opc_compute_ip_network" "test" {
|
||||
name = "testing-ip-network-%d"
|
||||
description = "testing-desc-%d"
|
||||
ip_address_prefix = "10.0.12.0/24"
|
||||
|
|
Loading…
Reference in New Issue