forked from hashicorp/terraform-provider-azurerm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimport_arm_image_test.go
49 lines (45 loc) · 1.42 KB
/
import_arm_image_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package azurerm
import (
"fmt"
"testing"
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
)
func TestAccAzureRMImage_importStandalone(t *testing.T) {
ri := acctest.RandInt()
resourceGroup := fmt.Sprintf("acctestRG-%d", ri)
userName := "testadmin"
password := "Password1234s!"
hostName := fmt.Sprintf("tftestcustomimagesrc%d", ri)
sshPort := "22"
location := testLocation()
preConfig := testAccAzureRMImage_standaloneImage_setup(ri, userName, password, hostName, location)
postConfig := testAccAzureRMImage_standaloneImage_provision(ri, userName, password, hostName, location)
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMImageDestroy,
Steps: []resource.TestStep{
{
//need to create a vm and then reference it in the image creation
Config: preConfig,
Destroy: false,
Check: resource.ComposeTestCheckFunc(
testCheckAzureVMExists("azurerm_virtual_machine.testsource", true),
testGeneralizeVMImage(resourceGroup, "testsource", userName, password, hostName, sshPort, location),
),
},
{
Config: postConfig,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMImageExists("azurerm_image.test", true),
),
},
{
ResourceName: "azurerm_image.test",
ImportState: true,
ImportStateVerify: true,
},
},
})
}