|
1 | 1 | package cockpit_test |
2 | 2 |
|
3 | 3 | import ( |
| 4 | + "fmt" |
4 | 5 | "testing" |
5 | 6 |
|
6 | 7 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" |
@@ -33,6 +34,8 @@ func TestAccCockpit_Basic(t *testing.T) { |
33 | 34 | resource.TestCheckResourceAttrSet("scaleway_cockpit.main", "plan"), |
34 | 35 | resource.TestCheckResourceAttrSet("scaleway_cockpit.main", "plan_id"), |
35 | 36 | resource.TestCheckResourceAttr("scaleway_cockpit.main", "plan", "free"), |
| 37 | + resource.TestCheckResourceAttrSet("scaleway_cockpit.main", "endpoints.0.grafana_url"), |
| 38 | + checkGrafanaURL("scaleway_cockpit.main", "scaleway_account_project.project"), |
36 | 39 | ), |
37 | 40 | }, |
38 | 41 | { |
@@ -128,6 +131,20 @@ func TestAccCockpit_WithSourceEndpoints(t *testing.T) { |
128 | 131 | }) |
129 | 132 | } |
130 | 133 |
|
| 134 | +func checkGrafanaURL(resourceName, projectResource string) resource.TestCheckFunc { |
| 135 | + return func(s *terraform.State) error { |
| 136 | + rs, ok := s.RootModule().Resources[projectResource] |
| 137 | + if !ok { |
| 138 | + return fmt.Errorf("Not found: %s", projectResource) |
| 139 | + } |
| 140 | + |
| 141 | + projectID := rs.Primary.ID |
| 142 | + expectedURL := fmt.Sprintf("https://%s.dashboards.obs.fr-par.scw.cloud", projectID) |
| 143 | + |
| 144 | + return resource.TestCheckResourceAttr(resourceName, "endpoints.0.grafana_url", expectedURL)(s) |
| 145 | + } |
| 146 | +} |
| 147 | + |
131 | 148 | func isCockpitDestroyed(_ *acctest.TestTools) resource.TestCheckFunc { |
132 | 149 | return func(_ *terraform.State) error { |
133 | 150 | return nil |
|
0 commit comments