Skip to content

Commit

Permalink
test: make sure that old and new implementation is the same
Browse files Browse the repository at this point in the history
  • Loading branch information
apricote committed Nov 14, 2023
1 parent 81d4d25 commit e42f420
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 7 deletions.
3 changes: 2 additions & 1 deletion internal/datacenter/data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/types"

"github.com/hetznercloud/hcloud-go/hcloud"
"github.com/hetznercloud/terraform-provider-hcloud/internal/hcclient"
)
Expand Down Expand Up @@ -155,7 +156,7 @@ Use this resource to get detailed information about specific datacenter.
## Example Usage
` + "```" + `hcl
data "hcloud_datacenter" "ds_1" {
name = "fsn1-dc8"
name = "fsn1-dc14"
}
data "hcloud_datacenter" "ds_2" {
id = 4
Expand Down
18 changes: 16 additions & 2 deletions internal/e2etests/datacenter/data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package datacenter_test
import (
"testing"

"github.com/hashicorp/terraform-plugin-testing/helper/resource"

"github.com/hetznercloud/terraform-provider-hcloud/internal/datacenter"
"github.com/hetznercloud/terraform-provider-hcloud/internal/e2etests"

"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hetznercloud/terraform-provider-hcloud/internal/testtemplate"
)

Expand Down Expand Up @@ -63,19 +63,33 @@ func TestAccHcloudDataSourceDatacenter_UpgradePluginFramework(t *testing.T) {
VersionConstraint: "1.42.1",
Source: "hetznercloud/hcloud",
},
"null": {
VersionConstraint: "3.2.1",
Source: "hashicorp/null",
},
},

Config: tmplMan.Render(t,
"testdata/d/hcloud_datacenter", dcByName,
"testdata/d/hcloud_datacenter", dcByID,
"testdata/r/null_resource", dcByName,
"testdata/r/null_resource", dcByID,
),
},
{
ExternalProviders: map[string]resource.ExternalProvider{
"null": {
VersionConstraint: "3.2.1",
Source: "hashicorp/null",
},
},
ProtoV6ProviderFactories: e2etests.ProtoV6ProviderFactories(),

Config: tmplMan.Render(t,
"testdata/d/hcloud_datacenter", dcByName,
"testdata/d/hcloud_datacenter", dcByID,
"testdata/r/null_resource", dcByName,
"testdata/r/null_resource", dcByID,
),

PlanOnly: true,
Expand Down
7 changes: 3 additions & 4 deletions internal/e2etests/firewall/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ import (
"fmt"
"testing"

"github.com/hetznercloud/terraform-provider-hcloud/internal/e2etests"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/stretchr/testify/assert"

"github.com/hetznercloud/terraform-provider-hcloud/internal/firewall"

"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hetznercloud/hcloud-go/hcloud"
"github.com/hetznercloud/terraform-provider-hcloud/internal/e2etests"
"github.com/hetznercloud/terraform-provider-hcloud/internal/firewall"
"github.com/hetznercloud/terraform-provider-hcloud/internal/testsupport"
"github.com/hetznercloud/terraform-provider-hcloud/internal/testtemplate"
)
Expand Down
1 change: 1 addition & 0 deletions internal/e2etests/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"testing"

"github.com/hashicorp/terraform-plugin-go/tfprotov6"

"github.com/hetznercloud/hcloud-go/hcloud"
tfhcloud "github.com/hetznercloud/terraform-provider-hcloud/hcloud"
)
Expand Down
9 changes: 9 additions & 0 deletions internal/testdata/r/null_resource.tf.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// This template can be used to work around a bug/limitation in terraform-test-framework, which only checks for plan
// changes in resources, not in datasources or outputs.
// You can pass any [testtemplate.DataCommon] to it.

resource "null_resource" "{{ .RName }}" {
triggers = {
resource = jsonencode({{ .TFID }})
}
}

0 comments on commit e42f420

Please sign in to comment.