Skip to content

Commit e3b3d90

Browse files
committed
feat: add tests for additional CloudStack limits resource types
1 parent 3494af6 commit e3b3d90

File tree

2 files changed

+170
-5
lines changed

2 files changed

+170
-5
lines changed

cloudstack/resource_cloudstack_limits.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ var resourceTypeMap = map[string]int{
4343
"memory": 9,
4444
"primarystorage": 10,
4545
"secondarystorage": 11,
46-
"publicip": 12,
47-
"eip": 13,
48-
"autoscalevmgroup": 14,
4946
}
5047

5148
func resourceCloudStackLimits() *schema.Resource {
@@ -61,11 +58,11 @@ func resourceCloudStackLimits() *schema.Resource {
6158
ForceNew: true,
6259
ValidateFunc: validation.StringInSlice([]string{
6360
"instance", "ip", "volume", "snapshot", "template", "project", "network", "vpc",
64-
"cpu", "memory", "primarystorage", "secondarystorage", "publicip", "eip", "autoscalevmgroup",
61+
"cpu", "memory", "primarystorage", "secondarystorage",
6562
}, false), // false disables case-insensitive matching
6663
Description: "The type of resource to update the limits. Available types are: " +
6764
"instance, ip, volume, snapshot, template, project, network, vpc, cpu, memory, " +
68-
"primarystorage, secondarystorage, publicip, eip, autoscalevmgroup",
65+
"primarystorage, secondarystorage",
6966
},
7067
"account": {
7168
Type: schema.TypeString,

cloudstack/resource_cloudstack_limits_test.go

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,126 @@ func TestAccCloudStackLimits_stringType(t *testing.T) {
207207
})
208208
}
209209

210+
func TestAccCloudStackLimits_ip(t *testing.T) {
211+
resource.Test(t, resource.TestCase{
212+
PreCheck: func() { testAccPreCheck(t) },
213+
Providers: testAccProviders,
214+
CheckDestroy: testAccCheckCloudStackLimitsDestroy,
215+
Steps: []resource.TestStep{
216+
{
217+
Config: testAccCloudStackLimits_domain + testAccCloudStackLimits_ip,
218+
Check: resource.ComposeTestCheckFunc(
219+
testAccCheckCloudStackLimitsExists("cloudstack_limits.ip_limit"),
220+
resource.TestCheckResourceAttr(
221+
"cloudstack_limits.ip_limit", "type", "ip"),
222+
resource.TestCheckResourceAttr(
223+
"cloudstack_limits.ip_limit", "max", "25"),
224+
),
225+
},
226+
},
227+
})
228+
}
229+
230+
func TestAccCloudStackLimits_template(t *testing.T) {
231+
resource.Test(t, resource.TestCase{
232+
PreCheck: func() { testAccPreCheck(t) },
233+
Providers: testAccProviders,
234+
CheckDestroy: testAccCheckCloudStackLimitsDestroy,
235+
Steps: []resource.TestStep{
236+
{
237+
Config: testAccCloudStackLimits_domain + testAccCloudStackLimits_template,
238+
Check: resource.ComposeTestCheckFunc(
239+
testAccCheckCloudStackLimitsExists("cloudstack_limits.template_limit"),
240+
resource.TestCheckResourceAttr(
241+
"cloudstack_limits.template_limit", "type", "template"),
242+
resource.TestCheckResourceAttr(
243+
"cloudstack_limits.template_limit", "max", "40"),
244+
),
245+
},
246+
},
247+
})
248+
}
249+
250+
func TestAccCloudStackLimits_projectType(t *testing.T) {
251+
resource.Test(t, resource.TestCase{
252+
PreCheck: func() { testAccPreCheck(t) },
253+
Providers: testAccProviders,
254+
CheckDestroy: testAccCheckCloudStackLimitsDestroy,
255+
Steps: []resource.TestStep{
256+
{
257+
Config: testAccCloudStackLimits_domain + testAccCloudStackLimits_projectType,
258+
Check: resource.ComposeTestCheckFunc(
259+
testAccCheckCloudStackLimitsExists("cloudstack_limits.project_type_limit"),
260+
resource.TestCheckResourceAttr(
261+
"cloudstack_limits.project_type_limit", "type", "project"),
262+
resource.TestCheckResourceAttr(
263+
"cloudstack_limits.project_type_limit", "max", "15"),
264+
),
265+
},
266+
},
267+
})
268+
}
269+
270+
func TestAccCloudStackLimits_vpc(t *testing.T) {
271+
resource.Test(t, resource.TestCase{
272+
PreCheck: func() { testAccPreCheck(t) },
273+
Providers: testAccProviders,
274+
CheckDestroy: testAccCheckCloudStackLimitsDestroy,
275+
Steps: []resource.TestStep{
276+
{
277+
Config: testAccCloudStackLimits_domain + testAccCloudStackLimits_vpc,
278+
Check: resource.ComposeTestCheckFunc(
279+
testAccCheckCloudStackLimitsExists("cloudstack_limits.vpc_limit"),
280+
resource.TestCheckResourceAttr(
281+
"cloudstack_limits.vpc_limit", "type", "vpc"),
282+
resource.TestCheckResourceAttr(
283+
"cloudstack_limits.vpc_limit", "max", "10"),
284+
),
285+
},
286+
},
287+
})
288+
}
289+
290+
func TestAccCloudStackLimits_memory(t *testing.T) {
291+
resource.Test(t, resource.TestCase{
292+
PreCheck: func() { testAccPreCheck(t) },
293+
Providers: testAccProviders,
294+
CheckDestroy: testAccCheckCloudStackLimitsDestroy,
295+
Steps: []resource.TestStep{
296+
{
297+
Config: testAccCloudStackLimits_domain + testAccCloudStackLimits_memory,
298+
Check: resource.ComposeTestCheckFunc(
299+
testAccCheckCloudStackLimitsExists("cloudstack_limits.memory_limit"),
300+
resource.TestCheckResourceAttr(
301+
"cloudstack_limits.memory_limit", "type", "memory"),
302+
resource.TestCheckResourceAttr(
303+
"cloudstack_limits.memory_limit", "max", "8192"),
304+
),
305+
},
306+
},
307+
})
308+
}
309+
310+
func TestAccCloudStackLimits_secondarystorage(t *testing.T) {
311+
resource.Test(t, resource.TestCase{
312+
PreCheck: func() { testAccPreCheck(t) },
313+
Providers: testAccProviders,
314+
CheckDestroy: testAccCheckCloudStackLimitsDestroy,
315+
Steps: []resource.TestStep{
316+
{
317+
Config: testAccCloudStackLimits_domain + testAccCloudStackLimits_secondarystorage,
318+
Check: resource.ComposeTestCheckFunc(
319+
testAccCheckCloudStackLimitsExists("cloudstack_limits.secondarystorage_limit"),
320+
resource.TestCheckResourceAttr(
321+
"cloudstack_limits.secondarystorage_limit", "type", "secondarystorage"),
322+
resource.TestCheckResourceAttr(
323+
"cloudstack_limits.secondarystorage_limit", "max", "2000"),
324+
),
325+
},
326+
},
327+
})
328+
}
329+
210330
func TestAccCloudStackLimits_import(t *testing.T) {
211331
resource.Test(t, resource.TestCase{
212332
PreCheck: func() { testAccPreCheck(t) },
@@ -287,3 +407,51 @@ resource "cloudstack_limits" "string_type" {
287407
domainid = cloudstack_domain.test_domain.id
288408
}
289409
`
410+
411+
const testAccCloudStackLimits_ip = `
412+
resource "cloudstack_limits" "ip_limit" {
413+
type = "ip"
414+
max = 25
415+
domainid = cloudstack_domain.test_domain.id
416+
}
417+
`
418+
419+
const testAccCloudStackLimits_template = `
420+
resource "cloudstack_limits" "template_limit" {
421+
type = "template"
422+
max = 40
423+
domainid = cloudstack_domain.test_domain.id
424+
}
425+
`
426+
427+
const testAccCloudStackLimits_projectType = `
428+
resource "cloudstack_limits" "project_type_limit" {
429+
type = "project"
430+
max = 15
431+
domainid = cloudstack_domain.test_domain.id
432+
}
433+
`
434+
435+
const testAccCloudStackLimits_vpc = `
436+
resource "cloudstack_limits" "vpc_limit" {
437+
type = "vpc"
438+
max = 10
439+
domainid = cloudstack_domain.test_domain.id
440+
}
441+
`
442+
443+
const testAccCloudStackLimits_memory = `
444+
resource "cloudstack_limits" "memory_limit" {
445+
type = "memory"
446+
max = 8192
447+
domainid = cloudstack_domain.test_domain.id
448+
}
449+
`
450+
451+
const testAccCloudStackLimits_secondarystorage = `
452+
resource "cloudstack_limits" "secondarystorage_limit" {
453+
type = "secondarystorage"
454+
max = 2000
455+
domainid = cloudstack_domain.test_domain.id
456+
}
457+
`

0 commit comments

Comments
 (0)