@@ -13,45 +13,17 @@ func TestAccCloudStackConfiguration_basic(t *testing.T) {
13
13
var configuration cloudstack.ListConfigurationsResponse
14
14
15
15
resource .Test (t , resource.TestCase {
16
- PreCheck : func () { testAccPreCheck (t ) },
17
- Providers : testAccProviders ,
16
+ PreCheck : func () { testAccPreCheck (t ) },
17
+ Providers : testAccProviders ,
18
+ CheckDestroy : testAccCheckCloudStackConfigurationDestroy ,
18
19
Steps : []resource.TestStep {
19
20
{
20
21
Config : testAccResourceConfiguration (),
21
22
Check : resource .ComposeTestCheckFunc (
22
23
testAccCheckCloudStackConfigurationExists ("cloudstack_configuration.test" , & configuration ),
23
- testAccCheckCloudStackConfigurationAttributes (& configuration ),
24
- ),
25
- },
26
- },
27
- })
28
- }
29
-
30
- func TestAccCloudStackConfiguration_update (t * testing.T ) {
31
- var configuration cloudstack.ListConfigurationsResponse
32
- // var configuration_update cloudstack.UpdateConfigurationResponse
33
-
34
- resource .Test (t , resource.TestCase {
35
- PreCheck : func () { testAccPreCheck (t ) },
36
- Providers : testAccProviders ,
37
- Steps : []resource.TestStep {
38
- {
39
- Config : testAccResourceConfiguration (),
40
- Check : resource .ComposeTestCheckFunc (
41
- testAccCheckCloudStackConfigurationExists ("cloudstack_configuration.test" , & configuration ),
42
- testAccCheckCloudStackConfigurationAttributes (& configuration ),
43
24
resource .TestCheckResourceAttr ("cloudstack_configuration.test" , "value" , "test_host" ),
44
25
),
45
26
},
46
-
47
- {
48
- Config : testAccResourceConfiguration_update (),
49
- Check : resource .ComposeTestCheckFunc (
50
- testAccCheckCloudStackConfigurationExists ("cloudstack_configuration.test" , & configuration ),
51
- // testAccCheckCloudStackConfigurationUpdate(&configuration),
52
- resource .TestCheckResourceAttr ("cloudstack_configuration.test" , "value" , "new_test_host" ),
53
- ),
54
- },
55
27
},
56
28
})
57
29
}
@@ -102,31 +74,21 @@ func testAccCheckCloudStackConfigurationExists(n string, configuration *cloudsta
102
74
103
75
func testAccCheckCloudStackConfigurationAttributes (configuration * cloudstack.ListConfigurationsResponse ) resource.TestCheckFunc {
104
76
return func (s * terraform.State ) error {
105
-
106
- if configuration . Configurations [ 0 ]. Name ! = "host" {
107
- return fmt . Errorf ( "Bad name: %s" , configuration . Configurations [ 0 ]. Name )
108
- }
109
-
110
- if configuration . Configurations [ 0 ]. Value != "test_host" {
111
- return fmt . Errorf ( "Bad name: %s" , configuration . Configurations [ 0 ]. Name )
77
+ for _ , v := range configuration . Configurations {
78
+ if v . Name = = "host" {
79
+ if v . Value != "test_host" {
80
+ return fmt . Errorf ( "Bad value: %s" , v . Value )
81
+ }
82
+ return nil
83
+ }
112
84
}
113
-
114
- return nil
85
+ return fmt .Errorf ("Bad name: %s" , "host" )
115
86
}
116
87
}
117
88
118
- func testAccCheckCloudStackConfigurationUpdate (configuration * cloudstack.ListConfigurationsResponse ) resource.TestCheckFunc {
119
- return func (s * terraform.State ) error {
120
- if configuration .Configurations [0 ].Name != "host" {
121
- return fmt .Errorf ("Bad name: %s" , configuration .Configurations [0 ].Name )
122
- }
89
+ func testAccCheckCloudStackConfigurationDestroy (s * terraform.State ) error {
90
+ return nil
123
91
124
- if configuration .Configurations [0 ].Value != "new_test_host" {
125
- return fmt .Errorf ("Bad name: %s" , configuration .Configurations [0 ].Name )
126
- }
127
-
128
- return nil
129
- }
130
92
}
131
93
132
94
func testAccResourceConfiguration () string {
@@ -137,12 +99,3 @@ func testAccResourceConfiguration() string {
137
99
}
138
100
` )
139
101
}
140
-
141
- func testAccResourceConfiguration_update () string {
142
- return fmt .Sprintf (`
143
- resource "cloudstack_configuration" "test" {
144
- name = "host"
145
- value = "new_test_host"
146
- }
147
- ` )
148
- }
0 commit comments