@@ -13,45 +13,17 @@ func TestAccCloudStackConfiguration_basic(t *testing.T) {
1313 var configuration cloudstack.ListConfigurationsResponse
1414
1515 resource .Test (t , resource.TestCase {
16- PreCheck : func () { testAccPreCheck (t ) },
17- Providers : testAccProviders ,
16+ PreCheck : func () { testAccPreCheck (t ) },
17+ Providers : testAccProviders ,
18+ CheckDestroy : testAccCheckCloudStackConfigurationDestroy ,
1819 Steps : []resource.TestStep {
1920 {
2021 Config : testAccResourceConfiguration (),
2122 Check : resource .ComposeTestCheckFunc (
2223 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 ),
4324 resource .TestCheckResourceAttr ("cloudstack_configuration.test" , "value" , "test_host" ),
4425 ),
4526 },
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- },
5527 },
5628 })
5729}
@@ -102,31 +74,21 @@ func testAccCheckCloudStackConfigurationExists(n string, configuration *cloudsta
10274
10375func testAccCheckCloudStackConfigurationAttributes (configuration * cloudstack.ListConfigurationsResponse ) resource.TestCheckFunc {
10476 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+ }
11284 }
113-
114- return nil
85+ return fmt .Errorf ("Bad name: %s" , "host" )
11586 }
11687}
11788
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
12391
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- }
13092}
13193
13294func testAccResourceConfiguration () string {
@@ -137,12 +99,3 @@ func testAccResourceConfiguration() string {
13799 }
138100` )
139101}
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