Skip to content

Commit 6c7f632

Browse files
committed
added test creating instance with project id, added const in provider_test
1 parent 5687045 commit 6c7f632

2 files changed

Lines changed: 41 additions & 0 deletions

File tree

builtin/providers/cloudstack/provider_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,6 @@ var CLOUDSTACK_TEMPLATE_FORMAT = ""
8787
var CLOUDSTACK_TEMPLATE_URL = ""
8888
var CLOUDSTACK_TEMPLATE_OS_TYPE = ""
8989
var CLOUDSTACK_ZONE = ""
90+
var CLOUDSTACK_PROJECT_NAME = ""
91+
var CLOUDSTACK_PROJECT_ID = ""
92+

builtin/providers/cloudstack/resource_cloudstack_instance_test.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,27 @@ func TestAccCloudStackInstance_Projectname(t *testing.T) {
108108
})
109109
}
110110

111+
func TestAccCloudStackInstance_Projectid(t *testing.T) {
112+
var instance cloudstack.VirtualMachine
113+
114+
resource.Test(t, resource.TestCase{
115+
PreCheck: func() { testAccPreCheck(t) },
116+
Providers: testAccProviders,
117+
CheckDestroy: testAccCheckCloudStackInstanceDestroy,
118+
Steps: []resource.TestStep{
119+
resource.TestStep{
120+
Config: testAccCloudStackInstance_projectid,
121+
Check: resource.ComposeTestCheckFunc(
122+
testAccCheckCloudStackInstanceExists(
123+
"cloudstack_instance.foobar", &instance),
124+
resource.TestCheckResourceAttr(
125+
"cloudstack_instance.foobar", "project", CLOUDSTACK_PROJECT_ID),
126+
),
127+
},
128+
},
129+
})
130+
}
131+
111132
func testAccCheckCloudStackInstanceExists(
112133
n string, instance *cloudstack.VirtualMachine) resource.TestCheckFunc {
113134
return func(s *terraform.State) error {
@@ -272,3 +293,20 @@ resource "cloudstack_instance" "foobar" {
272293
CLOUDSTACK_TEMPLATE,
273294
CLOUDSTACK_ZONE,
274295
CLOUDSTACK_PROJECT_NAME)
296+
297+
var testAccCloudStackInstance_projectid = fmt.Sprintf(`
298+
resource "cloudstack_instance" "foobar" {
299+
name = "terraform-test"
300+
display_name = "terraform"
301+
service_offering= "%s"
302+
network = "%s"
303+
template = "%s"
304+
zone = "%s"
305+
expunge = true
306+
project = "%s"
307+
}`,
308+
CLOUDSTACK_SERVICE_OFFERING_1,
309+
CLOUDSTACK_NETWORK_1,
310+
CLOUDSTACK_TEMPLATE,
311+
CLOUDSTACK_ZONE,
312+
CLOUDSTACK_PROJECT_id)

0 commit comments

Comments
 (0)