github.com/recobe182/terraform@v0.8.5-0.20170117231232-49ab22a935b7/builtin/providers/google/import_compute_instance_group_manager_test.go (about)

     1  package google
     2  
     3  import (
     4  	"fmt"
     5  	"testing"
     6  
     7  	"github.com/hashicorp/terraform/helper/acctest"
     8  	"github.com/hashicorp/terraform/helper/resource"
     9  )
    10  
    11  func TestAccInstanceGroupManager_importBasic(t *testing.T) {
    12  	resourceName1 := "google_compute_instance_group_manager.igm-basic"
    13  	resourceName2 := "google_compute_instance_group_manager.igm-no-tp"
    14  	template := fmt.Sprintf("igm-test-%s", acctest.RandString(10))
    15  	target := fmt.Sprintf("igm-test-%s", acctest.RandString(10))
    16  	igm1 := fmt.Sprintf("igm-test-%s", acctest.RandString(10))
    17  	igm2 := fmt.Sprintf("igm-test-%s", acctest.RandString(10))
    18  
    19  	resource.Test(t, resource.TestCase{
    20  		PreCheck:     func() { testAccPreCheck(t) },
    21  		Providers:    testAccProviders,
    22  		CheckDestroy: testAccCheckInstanceGroupManagerDestroy,
    23  		Steps: []resource.TestStep{
    24  			resource.TestStep{
    25  				Config: testAccInstanceGroupManager_basic(template, target, igm1, igm2),
    26  			},
    27  
    28  			resource.TestStep{
    29  				ResourceName:      resourceName1,
    30  				ImportState:       true,
    31  				ImportStateVerify: true,
    32  			},
    33  
    34  			resource.TestStep{
    35  				ResourceName:      resourceName2,
    36  				ImportState:       true,
    37  				ImportStateVerify: true,
    38  			},
    39  		},
    40  	})
    41  }
    42  
    43  func TestAccInstanceGroupManager_importUpdate(t *testing.T) {
    44  	resourceName := "google_compute_instance_group_manager.igm-update"
    45  	template := fmt.Sprintf("igm-test-%s", acctest.RandString(10))
    46  	target := fmt.Sprintf("igm-test-%s", acctest.RandString(10))
    47  	igm := fmt.Sprintf("igm-test-%s", acctest.RandString(10))
    48  
    49  	resource.Test(t, resource.TestCase{
    50  		PreCheck:     func() { testAccPreCheck(t) },
    51  		Providers:    testAccProviders,
    52  		CheckDestroy: testAccCheckInstanceGroupManagerDestroy,
    53  		Steps: []resource.TestStep{
    54  			resource.TestStep{
    55  				Config: testAccInstanceGroupManager_update(template, target, igm),
    56  			},
    57  
    58  			resource.TestStep{
    59  				ResourceName:      resourceName,
    60  				ImportState:       true,
    61  				ImportStateVerify: true,
    62  			},
    63  		},
    64  	})
    65  }