@@ -31,13 +31,15 @@ func TestAccCockpitSource_Basic_metrics(t *testing.T) {
31
31
project_id = scaleway_account_project.project.id
32
32
name = "my-source"
33
33
type = "metrics"
34
+ retention_days = 31
34
35
}
35
36
` ,
36
37
Check : resource .ComposeTestCheckFunc (
37
38
isSourcePresent (tt , "scaleway_cockpit_source.main" ),
38
39
resource .TestCheckResourceAttr ("scaleway_cockpit_source.main" , "name" , "my-source" ),
39
40
resource .TestCheckResourceAttr ("scaleway_cockpit_source.main" , "type" , "metrics" ),
40
41
resource .TestCheckResourceAttr ("scaleway_cockpit_source.main" , "region" , "fr-par" ),
42
+ resource .TestCheckResourceAttr ("scaleway_cockpit_source.main" , "retention_days" , "31" ),
41
43
resource .TestCheckResourceAttrSet ("scaleway_cockpit_source.main" , "url" ),
42
44
resource .TestCheckResourceAttrSet ("scaleway_cockpit_source.main" , "push_url" ),
43
45
resource .TestCheckResourceAttrSet ("scaleway_cockpit_source.main" , "origin" ),
@@ -70,13 +72,57 @@ func TestAccCockpitSource_Basic_logs(t *testing.T) {
70
72
project_id = scaleway_account_project.project.id
71
73
name = "my-source"
72
74
type = "logs"
75
+ retention_days = 31
76
+
77
+ }
78
+ ` ,
79
+ Check : resource .ComposeTestCheckFunc (
80
+ isSourcePresent (tt , "scaleway_cockpit_source.main" ),
81
+ resource .TestCheckResourceAttr ("scaleway_cockpit_source.main" , "name" , "my-source" ),
82
+ resource .TestCheckResourceAttr ("scaleway_cockpit_source.main" , "type" , "logs" ),
83
+ resource .TestCheckResourceAttr ("scaleway_cockpit_source.main" , "region" , "fr-par" ),
84
+ resource .TestCheckResourceAttrSet ("scaleway_cockpit_source.main" , "url" ),
85
+ resource .TestCheckResourceAttrSet ("scaleway_cockpit_source.main" , "push_url" ),
86
+ resource .TestCheckResourceAttrSet ("scaleway_cockpit_source.main" , "origin" ),
87
+ resource .TestCheckResourceAttrSet ("scaleway_cockpit_source.main" , "created_at" ),
88
+ resource .TestCheckResourceAttrSet ("scaleway_cockpit_source.main" , "updated_at" ),
89
+ resource .TestCheckResourceAttrSet ("scaleway_cockpit_source.main" , "synchronized_with_grafana" ),
90
+ resource .TestCheckResourceAttrPair ("scaleway_cockpit_source.main" , "project_id" , "scaleway_account_project.project" , "id" ),
91
+ ),
92
+ },
93
+ },
94
+ })
95
+ }
96
+
97
+ func TestAccCockpitSource_retention_days (t * testing.T ) {
98
+ tt := acctest .NewTestTools (t )
99
+ defer tt .Cleanup ()
100
+
101
+ resource .ParallelTest (t , resource.TestCase {
102
+ PreCheck : func () { acctest .PreCheck (t ) },
103
+ ProviderFactories : tt .ProviderFactories ,
104
+ CheckDestroy : isSourceDestroyed (tt ),
105
+ Steps : []resource.TestStep {
106
+ {
107
+ Config : `
108
+ resource "scaleway_account_project" "project" {
109
+ name = "tf_tests_cockpit_datasource_basic"
110
+ }
111
+
112
+ resource "scaleway_cockpit_source" "main" {
113
+ project_id = scaleway_account_project.project.id
114
+ name = "my-source"
115
+ type = "logs"
116
+ retention_days = 13
117
+
73
118
}
74
119
` ,
75
120
Check : resource .ComposeTestCheckFunc (
76
121
isSourcePresent (tt , "scaleway_cockpit_source.main" ),
77
122
resource .TestCheckResourceAttr ("scaleway_cockpit_source.main" , "name" , "my-source" ),
78
123
resource .TestCheckResourceAttr ("scaleway_cockpit_source.main" , "type" , "logs" ),
79
124
resource .TestCheckResourceAttr ("scaleway_cockpit_source.main" , "region" , "fr-par" ),
125
+ resource .TestCheckResourceAttr ("scaleway_cockpit_source.main" , "retention_days" , "13" ),
80
126
resource .TestCheckResourceAttrSet ("scaleway_cockpit_source.main" , "url" ),
81
127
resource .TestCheckResourceAttrSet ("scaleway_cockpit_source.main" , "push_url" ),
82
128
resource .TestCheckResourceAttrSet ("scaleway_cockpit_source.main" , "origin" ),
@@ -90,6 +136,75 @@ func TestAccCockpitSource_Basic_logs(t *testing.T) {
90
136
})
91
137
}
92
138
139
+ func TestAccCockpitSource_Update (t * testing.T ) {
140
+ tt := acctest .NewTestTools (t )
141
+ defer tt .Cleanup ()
142
+
143
+ resource .ParallelTest (t , resource.TestCase {
144
+ PreCheck : func () { acctest .PreCheck (t ) },
145
+ ProviderFactories : tt .ProviderFactories ,
146
+ CheckDestroy : isSourceDestroyed (tt ),
147
+ Steps : []resource.TestStep {
148
+ // Initial creation
149
+ {
150
+ Config : `
151
+ resource "scaleway_account_project" "project" {
152
+ name = "tf_tests_cockpit_source_update"
153
+ }
154
+
155
+ resource "scaleway_cockpit_source" "main" {
156
+ project_id = scaleway_account_project.project.id
157
+ name = "initial-name"
158
+ type = "logs"
159
+ retention_days = 10
160
+ }
161
+ ` ,
162
+ Check : resource .ComposeTestCheckFunc (
163
+ isSourcePresent (tt , "scaleway_cockpit_source.main" ),
164
+ resource .TestCheckResourceAttr ("scaleway_cockpit_source.main" , "name" , "initial-name" ),
165
+ resource .TestCheckResourceAttr ("scaleway_cockpit_source.main" , "retention_days" , "10" ),
166
+ ),
167
+ },
168
+ {
169
+ Config : `
170
+ resource "scaleway_account_project" "project" {
171
+ name = "tf_tests_cockpit_source_update"
172
+ }
173
+
174
+ resource "scaleway_cockpit_source" "main" {
175
+ project_id = scaleway_account_project.project.id
176
+ name = "initial-name"
177
+ type = "logs"
178
+ retention_days = 20
179
+ }
180
+ ` ,
181
+ Check : resource .ComposeTestCheckFunc (
182
+ isSourcePresent (tt , "scaleway_cockpit_source.main" ),
183
+ resource .TestCheckResourceAttr ("scaleway_cockpit_source.main" , "retention_days" , "20" ),
184
+ ),
185
+ },
186
+ {
187
+ Config : `
188
+ resource "scaleway_account_project" "project" {
189
+ name = "tf_tests_cockpit_source_update"
190
+ }
191
+
192
+ resource "scaleway_cockpit_source" "main" {
193
+ project_id = scaleway_account_project.project.id
194
+ name = "updated-name"
195
+ type = "logs"
196
+ retention_days = 20
197
+ }
198
+ ` ,
199
+ Check : resource .ComposeTestCheckFunc (
200
+ isSourcePresent (tt , "scaleway_cockpit_source.main" ),
201
+ resource .TestCheckResourceAttr ("scaleway_cockpit_source.main" , "name" , "updated-name" ),
202
+ ),
203
+ },
204
+ },
205
+ })
206
+ }
207
+
93
208
func isSourcePresent (tt * acctest.TestTools , n string ) resource.TestCheckFunc {
94
209
return func (state * terraform.State ) error {
95
210
rs , ok := state .RootModule ().Resources [n ]
0 commit comments