Skip to content

Commit

Permalink
Fix examples test
Browse files Browse the repository at this point in the history
  • Loading branch information
julienduchesne committed Mar 21, 2024
1 parent 86780e0 commit 3874073
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions internal/resources/examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"testing"

"github.com/grafana/terraform-provider-grafana/v2/internal/testutils"
"github.com/grafana/terraform-provider-grafana/v2/pkg/provider"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

Expand Down Expand Up @@ -131,7 +132,14 @@ func TestAccExamples(t *testing.T) {
}

// Sanity check that we have all resources and datasources have been tested
for rName := range testutils.Provider.ResourcesMap {
resourceNames := map[string]struct{}{}
for _, r := range provider.Resources() {
resourceNames[r.Name] = struct{}{}
}
for rName := range testutils.Provider.ResourcesMap { // TODO: Migrate to common.Resource instances (in Resources function)
resourceNames[rName] = struct{}{}
}
for rName := range resourceNames {
if _, ok := testedResources["resources/"+strings.TrimPrefix(rName, "grafana_")]; !ok {
t.Errorf("Resource %s was not tested", rName)
}
Expand All @@ -146,7 +154,7 @@ func TestAccExamples(t *testing.T) {
for rName := range testedResources {
if strings.HasPrefix(rName, "resources/") {
rName = "grafana_" + strings.TrimPrefix(rName, "resources/")
if _, ok := testutils.Provider.ResourcesMap[rName]; !ok {
if _, ok := resourceNames[rName]; !ok {
t.Errorf("Resource %s was tested but is not declared by the provider", rName)
}
}
Expand Down

0 comments on commit 3874073

Please sign in to comment.