Skip to content

Commit

Permalink
Use tfversion variables instead of go-version directly for function t…
Browse files Browse the repository at this point in the history
…esting

Reference: #220

Consuming developers should not directly need to worry about `github.com/hashicorp/go-version` unless they want to use that Go module. Provider-defined functions testing was releasing in this template repository before the Terraform 1.8.0 version variable in the terraform-plugin-testing `tfversion` package was available. Now that the variable is present, we can remove go-version as a direct dependency, simplifying both the code and dependency management slightly.
  • Loading branch information
bflad committed May 24, 2024
1 parent cfae236 commit 8f9dc0f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module github.com/hashicorp/terraform-provider-scaffolding-framework
go 1.21

require (
github.com/hashicorp/go-version v1.6.0
github.com/hashicorp/terraform-plugin-docs v0.19.2
github.com/hashicorp/terraform-plugin-framework v1.8.0
github.com/hashicorp/terraform-plugin-go v0.23.0
Expand Down Expand Up @@ -37,6 +36,7 @@ require (
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-plugin v1.6.0 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
github.com/hashicorp/hc-install v0.6.4 // indirect
github.com/hashicorp/hcl/v2 v2.20.1 // indirect
github.com/hashicorp/logutils v1.0.0 // indirect
Expand Down
7 changes: 3 additions & 4 deletions internal/provider/example_function_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@ import (
"regexp"
"testing"

"github.com/hashicorp/go-version"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hashicorp/terraform-plugin-testing/tfversion"
)

func TestExampleFunction_Known(t *testing.T) {
resource.UnitTest(t, resource.TestCase{
TerraformVersionChecks: []tfversion.TerraformVersionCheck{
tfversion.SkipBelow(version.Must(version.NewVersion("1.8.0"))),
tfversion.SkipBelow(tfversion.Version1_8_0),
},
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
Steps: []resource.TestStep{
Expand All @@ -36,7 +35,7 @@ func TestExampleFunction_Known(t *testing.T) {
func TestExampleFunction_Null(t *testing.T) {
resource.UnitTest(t, resource.TestCase{
TerraformVersionChecks: []tfversion.TerraformVersionCheck{
tfversion.SkipBelow(version.Must(version.NewVersion("1.8.0"))),
tfversion.SkipBelow(tfversion.Version1_8_0),
},
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
Steps: []resource.TestStep{
Expand All @@ -56,7 +55,7 @@ func TestExampleFunction_Null(t *testing.T) {
func TestExampleFunction_Unknown(t *testing.T) {
resource.UnitTest(t, resource.TestCase{
TerraformVersionChecks: []tfversion.TerraformVersionCheck{
tfversion.SkipBelow(version.Must(version.NewVersion("1.8.0"))),
tfversion.SkipBelow(tfversion.Version1_8_0),
},
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
Steps: []resource.TestStep{
Expand Down

0 comments on commit 8f9dc0f

Please sign in to comment.