@@ -133,6 +133,75 @@ func TestAccCockpitSource_retention_days(t *testing.T) {
133
133
})
134
134
}
135
135
136
+ func TestAccCockpitSource_Update (t * testing.T ) {
137
+ tt := acctest .NewTestTools (t )
138
+ defer tt .Cleanup ()
139
+
140
+ resource .ParallelTest (t , resource.TestCase {
141
+ PreCheck : func () { acctest .PreCheck (t ) },
142
+ ProviderFactories : tt .ProviderFactories ,
143
+ CheckDestroy : isSourceDestroyed (tt ),
144
+ Steps : []resource.TestStep {
145
+ // Initial creation
146
+ {
147
+ Config : `
148
+ resource "scaleway_account_project" "project" {
149
+ name = "tf_tests_cockpit_source_update"
150
+ }
151
+
152
+ resource "scaleway_cockpit_source" "main" {
153
+ project_id = scaleway_account_project.project.id
154
+ name = "initial-name"
155
+ type = "logs"
156
+ retention_days = 10
157
+ }
158
+ ` ,
159
+ Check : resource .ComposeTestCheckFunc (
160
+ isSourcePresent (tt , "scaleway_cockpit_source.main" ),
161
+ resource .TestCheckResourceAttr ("scaleway_cockpit_source.main" , "name" , "initial-name" ),
162
+ resource .TestCheckResourceAttr ("scaleway_cockpit_source.main" , "retention_days" , "10" ),
163
+ ),
164
+ },
165
+ {
166
+ Config : `
167
+ resource "scaleway_account_project" "project" {
168
+ name = "tf_tests_cockpit_source_update"
169
+ }
170
+
171
+ resource "scaleway_cockpit_source" "main" {
172
+ project_id = scaleway_account_project.project.id
173
+ name = "initial-name"
174
+ type = "logs"
175
+ retention_days = 20
176
+ }
177
+ ` ,
178
+ Check : resource .ComposeTestCheckFunc (
179
+ isSourcePresent (tt , "scaleway_cockpit_source.main" ),
180
+ resource .TestCheckResourceAttr ("scaleway_cockpit_source.main" , "retention_days" , "20" ),
181
+ ),
182
+ },
183
+ {
184
+ Config : `
185
+ resource "scaleway_account_project" "project" {
186
+ name = "tf_tests_cockpit_source_update"
187
+ }
188
+
189
+ resource "scaleway_cockpit_source" "main" {
190
+ project_id = scaleway_account_project.project.id
191
+ name = "updated-name"
192
+ type = "logs"
193
+ retention_days = 20
194
+ }
195
+ ` ,
196
+ Check : resource .ComposeTestCheckFunc (
197
+ isSourcePresent (tt , "scaleway_cockpit_source.main" ),
198
+ resource .TestCheckResourceAttr ("scaleway_cockpit_source.main" , "name" , "updated-name" ),
199
+ ),
200
+ },
201
+ },
202
+ })
203
+ }
204
+
136
205
func isSourcePresent (tt * acctest.TestTools , n string ) resource.TestCheckFunc {
137
206
return func (state * terraform.State ) error {
138
207
rs , ok := state .RootModule ().Resources [n ]
0 commit comments