From 37b9fa017180c54b523995e0d19f42fef750bf59 Mon Sep 17 00:00:00 2001 From: Brian Flad Date: Fri, 24 May 2024 12:40:10 -0400 Subject: [PATCH] Use tfversion variables instead of go-version directly for function testing (#221) Reference: https://github.com/hashicorp/terraform-provider-scaffolding-framework/pull/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. --- go.mod | 2 +- internal/provider/example_function_test.go | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index 84454d2..06ed51c 100644 --- a/go.mod +++ b/go.mod @@ -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 @@ -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 diff --git a/internal/provider/example_function_test.go b/internal/provider/example_function_test.go index d04f99a..f7b5bdd 100644 --- a/internal/provider/example_function_test.go +++ b/internal/provider/example_function_test.go @@ -7,7 +7,6 @@ import ( "regexp" "testing" - "github.com/hashicorp/go-version" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/tfversion" ) @@ -15,7 +14,7 @@ import ( 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{ @@ -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{ @@ -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{