Skip to content

Commit 5687045

Browse files
committed
added test for instance creation with project name
1 parent 7e49714 commit 5687045

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

builtin/providers/cloudstack/resource_cloudstack_instance_test.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,27 @@ func TestAccCloudStackInstance_fixedIP(t *testing.T) {
8787
})
8888
}
8989

90+
func TestAccCloudStackInstance_Projectname(t *testing.T) {
91+
var instance cloudstack.VirtualMachine
92+
93+
resource.Test(t, resource.TestCase{
94+
PreCheck: func() { testAccPreCheck(t) },
95+
Providers: testAccProviders,
96+
CheckDestroy: testAccCheckCloudStackInstanceDestroy,
97+
Steps: []resource.TestStep{
98+
resource.TestStep{
99+
Config: testAccCloudStackInstance_projectname,
100+
Check: resource.ComposeTestCheckFunc(
101+
testAccCheckCloudStackInstanceExists(
102+
"cloudstack_instance.foobar", &instance),
103+
resource.TestCheckResourceAttr(
104+
"cloudstack_instance.foobar", "project", CLOUDSTACK_PROJECT_NAME),
105+
),
106+
},
107+
},
108+
})
109+
}
110+
90111
func testAccCheckCloudStackInstanceExists(
91112
n string, instance *cloudstack.VirtualMachine) resource.TestCheckFunc {
92113
return func(s *terraform.State) error {
@@ -233,3 +254,21 @@ resource "cloudstack_instance" "foobar" {
233254
CLOUDSTACK_NETWORK_1_IPADDRESS,
234255
CLOUDSTACK_TEMPLATE,
235256
CLOUDSTACK_ZONE)
257+
258+
259+
var testAccCloudStackInstance_projectname = fmt.Sprintf(`
260+
resource "cloudstack_instance" "foobar" {
261+
name = "terraform-test"
262+
display_name = "terraform"
263+
service_offering= "%s"
264+
network = "%s"
265+
template = "%s"
266+
zone = "%s"
267+
expunge = true
268+
project = "%s"
269+
}`,
270+
CLOUDSTACK_SERVICE_OFFERING_1,
271+
CLOUDSTACK_NETWORK_1,
272+
CLOUDSTACK_TEMPLATE,
273+
CLOUDSTACK_ZONE,
274+
CLOUDSTACK_PROJECT_NAME)

0 commit comments

Comments
 (0)