|
7 | 7 | "testing"
|
8 | 8 |
|
9 | 9 | "github.com/grafana/grafana-openapi-client-go/models"
|
10 |
| - "github.com/grafana/terraform-provider-grafana/v2/internal/common" |
11 | 10 | "github.com/grafana/terraform-provider-grafana/v2/internal/resources/grafana"
|
12 | 11 | "github.com/grafana/terraform-provider-grafana/v2/internal/testutils"
|
13 | 12 |
|
@@ -159,48 +158,6 @@ func TestAccDashboard_computed_config(t *testing.T) {
|
159 | 158 | })
|
160 | 159 | }
|
161 | 160 |
|
162 |
| -func TestAccDashboard_folder(t *testing.T) { |
163 |
| - testutils.CheckOSSTestsEnabled(t) |
164 |
| - |
165 |
| - uid := acctest.RandString(10) |
166 |
| - |
167 |
| - var dashboard models.DashboardFullWithMeta |
168 |
| - var folder models.Folder |
169 |
| - |
170 |
| - resource.ParallelTest(t, resource.TestCase{ |
171 |
| - ProtoV5ProviderFactories: testutils.ProtoV5ProviderFactories, |
172 |
| - CheckDestroy: resource.ComposeTestCheckFunc( |
173 |
| - dashboardCheckExists.destroyed(&dashboard, nil), |
174 |
| - folderCheckExists.destroyed(&folder, nil), |
175 |
| - ), |
176 |
| - Steps: []resource.TestStep{ |
177 |
| - { |
178 |
| - Config: testAccDashboardFolder(uid, "grafana_folder.test_folder1.id"), |
179 |
| - Check: resource.ComposeTestCheckFunc( |
180 |
| - dashboardCheckExists.exists("grafana_dashboard.test_folder", &dashboard), |
181 |
| - folderCheckExists.exists("grafana_folder.test_folder1", &folder), |
182 |
| - testAccDashboardCheckExistsInFolder(&dashboard, &folder), |
183 |
| - resource.TestCheckResourceAttr("grafana_dashboard.test_folder", "id", "1:"+uid), // <org id>:<uid> |
184 |
| - resource.TestCheckResourceAttr("grafana_dashboard.test_folder", "uid", uid), |
185 |
| - resource.TestMatchResourceAttr("grafana_dashboard.test_folder", "folder", common.IDRegexp), |
186 |
| - ), |
187 |
| - }, |
188 |
| - // Update folder |
189 |
| - { |
190 |
| - Config: testAccDashboardFolder(uid, "grafana_folder.test_folder2.id"), |
191 |
| - Check: resource.ComposeTestCheckFunc( |
192 |
| - dashboardCheckExists.exists("grafana_dashboard.test_folder", &dashboard), |
193 |
| - folderCheckExists.exists("grafana_folder.test_folder2", &folder), |
194 |
| - testAccDashboardCheckExistsInFolder(&dashboard, &folder), |
195 |
| - resource.TestCheckResourceAttr("grafana_dashboard.test_folder", "id", "1:"+uid), // <org id>:<uid> |
196 |
| - resource.TestCheckResourceAttr("grafana_dashboard.test_folder", "uid", uid), |
197 |
| - resource.TestMatchResourceAttr("grafana_dashboard.test_folder", "folder", common.IDRegexp), |
198 |
| - ), |
199 |
| - }, |
200 |
| - }, |
201 |
| - }) |
202 |
| -} |
203 |
| - |
204 | 161 | func TestAccDashboard_folder_uid(t *testing.T) {
|
205 | 162 | testutils.CheckOSSTestsEnabled(t, ">=8.0.0") // UID in folders were added in v8
|
206 | 163 |
|
@@ -289,8 +246,8 @@ func TestAccDashboard_inOrg(t *testing.T) {
|
289 | 246 |
|
290 | 247 | func testAccDashboardCheckExistsInFolder(dashboard *models.DashboardFullWithMeta, folder *models.Folder) resource.TestCheckFunc {
|
291 | 248 | return func(s *terraform.State) error {
|
292 |
| - if dashboard.Meta.FolderID != folder.ID && folder.ID != 0 { |
293 |
| - return fmt.Errorf("dashboard.Folder(%d) does not match folder.ID(%d)", dashboard.Meta.FolderID, folder.ID) |
| 249 | + if dashboard.Meta.FolderUID != folder.UID && folder.UID != "" { |
| 250 | + return fmt.Errorf("dashboard.Folder(%s) does not match folder.ID(%s)", dashboard.Meta.FolderUID, folder.UID) |
294 | 251 | }
|
295 | 252 | return nil
|
296 | 253 | }
|
|
0 commit comments