Skip to content

Commit

Permalink
missed a few
Browse files Browse the repository at this point in the history
  • Loading branch information
bbasata committed Dec 20, 2024
1 parent 0c062bf commit 16515b5
Show file tree
Hide file tree
Showing 4 changed files with 285 additions and 245 deletions.
156 changes: 84 additions & 72 deletions tfversion/require_above_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,45 +20,49 @@ func Test_RequireAbove_Equal(t *testing.T) { //nolint:paralleltest
t.Setenv("TF_ACC_TERRAFORM_PATH", "")
t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.1.0")

r.UnitTest(t, r.TestCase{
ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){
"test": providerserver.NewProviderServer(testprovider.Provider{}),
},
TerraformVersionChecks: []tfversion.TerraformVersionCheck{
tfversion.RequireAbove(version.Must(version.NewVersion("1.1.0"))),
},
Steps: []r.TestStep{
{
//nullable argument only available in TF v1.1.0+
Config: `variable "a" {
testingiface.ExpectPass(t, func(mockT *testingiface.MockT) {
r.UnitTest(mockT, r.TestCase{
ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){
"test": providerserver.NewProviderServer(testprovider.Provider{}),
},
TerraformVersionChecks: []tfversion.TerraformVersionCheck{
tfversion.RequireAbove(version.Must(version.NewVersion("1.1.0"))),
},
Steps: []r.TestStep{
{
//nullable argument only available in TF v1.1.0+
Config: `variable "a" {
nullable = true
default = "hello"
}`,
},
},
},
})
})
}

func Test_RequireAbove_Higher(t *testing.T) { //nolint:paralleltest
t.Setenv("TF_ACC_TERRAFORM_PATH", "")
t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.1.1")

r.UnitTest(t, r.TestCase{
ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){
"test": providerserver.NewProviderServer(testprovider.Provider{}),
},
TerraformVersionChecks: []tfversion.TerraformVersionCheck{
tfversion.RequireAbove(version.Must(version.NewVersion("1.1.0"))),
},
Steps: []r.TestStep{
{
//nullable argument only available in TF v1.1.0+
Config: `variable "a" {
testingiface.ExpectPass(t, func(mockT *testingiface.MockT) {
r.UnitTest(mockT, r.TestCase{
ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){
"test": providerserver.NewProviderServer(testprovider.Provider{}),
},
TerraformVersionChecks: []tfversion.TerraformVersionCheck{
tfversion.RequireAbove(version.Must(version.NewVersion("1.1.0"))),
},
Steps: []r.TestStep{
{
//nullable argument only available in TF v1.1.0+
Config: `variable "a" {
nullable = true
default = "hello"
}`,
},
},
},
})
})
}

Expand Down Expand Up @@ -95,37 +99,41 @@ func Test_RequireAbove_Prerelease_EqualCoreVersion(t *testing.T) { //nolint:para
// core versions.
//
// Reference: https://github.com/hashicorp/terraform-plugin-testing/issues/303
r.UnitTest(t, r.TestCase{
ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){
"test": providerserver.NewProviderServer(testprovider.Provider{}),
},
TerraformVersionChecks: []tfversion.TerraformVersionCheck{
tfversion.RequireAbove(version.Must(version.NewVersion("1.8.0"))),
},
Steps: []r.TestStep{
{
Config: `//non-empty config`,
},
},
testingiface.ExpectPass(t, func(mockT *testingiface.MockT) {
r.UnitTest(mockT, r.TestCase{
ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){
"test": providerserver.NewProviderServer(testprovider.Provider{}),
},
TerraformVersionChecks: []tfversion.TerraformVersionCheck{
tfversion.RequireAbove(version.Must(version.NewVersion("1.8.0"))),
},
Steps: []r.TestStep{
{
Config: `//non-empty config`,
},
},
})
})
}

func Test_RequireAbove_Prerelease_EqualPrerelease(t *testing.T) { //nolint:paralleltest
t.Setenv("TF_ACC_TERRAFORM_PATH", "")
t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.8.0-rc1")

r.UnitTest(t, r.TestCase{
ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){
"test": providerserver.NewProviderServer(testprovider.Provider{}),
},
TerraformVersionChecks: []tfversion.TerraformVersionCheck{
tfversion.RequireAbove(version.Must(version.NewVersion("1.8.0-rc1"))),
},
Steps: []r.TestStep{
{
Config: `//non-empty config`,
},
},
testingiface.ExpectPass(t, func(mockT *testingiface.MockT) {
r.UnitTest(mockT, r.TestCase{
ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){
"test": providerserver.NewProviderServer(testprovider.Provider{}),
},
TerraformVersionChecks: []tfversion.TerraformVersionCheck{
tfversion.RequireAbove(version.Must(version.NewVersion("1.8.0-rc1"))),
},
Steps: []r.TestStep{
{
Config: `//non-empty config`,
},
},
})
})
}

Expand Down Expand Up @@ -183,18 +191,20 @@ func Test_RequireAbove_Prerelease_LowerCoreVersion(t *testing.T) { //nolint:para

// The 1.8.0-rc1 prerelease should always be considered to be
// above the 1.7.0 core version.
r.UnitTest(t, r.TestCase{
ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){
"test": providerserver.NewProviderServer(testprovider.Provider{}),
},
TerraformVersionChecks: []tfversion.TerraformVersionCheck{
tfversion.RequireAbove(version.Must(version.NewVersion("1.7.0"))),
},
Steps: []r.TestStep{
{
Config: `//non-empty config`,
},
},
testingiface.ExpectPass(t, func(mockT *testingiface.MockT) {
r.UnitTest(mockT, r.TestCase{
ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){
"test": providerserver.NewProviderServer(testprovider.Provider{}),
},
TerraformVersionChecks: []tfversion.TerraformVersionCheck{
tfversion.RequireAbove(version.Must(version.NewVersion("1.7.0"))),
},
Steps: []r.TestStep{
{
Config: `//non-empty config`,
},
},
})
})
}

Expand All @@ -204,17 +214,19 @@ func Test_RequireAbove_Prerelease_LowerPrerelease(t *testing.T) { //nolint:paral

// The 1.8.0-rc1 prerelease should always be considered to be
// above the 1.8.0-beta1 prerelease.
r.UnitTest(t, r.TestCase{
ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){
"test": providerserver.NewProviderServer(testprovider.Provider{}),
},
TerraformVersionChecks: []tfversion.TerraformVersionCheck{
tfversion.RequireAbove(version.Must(version.NewVersion("1.8.0-beta1"))),
},
Steps: []r.TestStep{
{
Config: `//non-empty config`,
},
},
testingiface.ExpectPass(t, func(mockT *testingiface.MockT) {
r.UnitTest(mockT, r.TestCase{
ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){
"test": providerserver.NewProviderServer(testprovider.Provider{}),
},
TerraformVersionChecks: []tfversion.TerraformVersionCheck{
tfversion.RequireAbove(version.Must(version.NewVersion("1.8.0-beta1"))),
},
Steps: []r.TestStep{
{
Config: `//non-empty config`,
},
},
})
})
}
82 changes: 44 additions & 38 deletions tfversion/require_below_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,27 @@ func Test_RequireBelow_Lower(t *testing.T) { //nolint:paralleltest
t.Setenv("TF_ACC_TERRAFORM_PATH", "")
t.Setenv("TF_ACC_TERRAFORM_VERSION", "1.2.0")

r.UnitTest(t, r.TestCase{
ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){
"test": func() (tfprotov6.ProviderServer, error) { //nolint:unparam // required signature
return nil, nil
},
},
TerraformVersionChecks: []tfversion.TerraformVersionCheck{
tfversion.RequireBelow(version.Must(version.NewVersion("1.3.0"))),
},
Steps: []r.TestStep{
{
//module_variable_optional_attrs experiment is deprecated in TF v1.3.0
Config: `
testingiface.ExpectPass(t, func(mockT *testingiface.MockT) {
r.UnitTest(mockT, r.TestCase{
ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){
"test": func() (tfprotov6.ProviderServer, error) { //nolint:unparam // required signature
return nil, nil
},
},
TerraformVersionChecks: []tfversion.TerraformVersionCheck{
tfversion.RequireBelow(version.Must(version.NewVersion("1.3.0"))),
},
Steps: []r.TestStep{
{
//module_variable_optional_attrs experiment is deprecated in TF v1.3.0
Config: `
terraform {
experiments = [module_variable_optional_attrs]
}
`,
},
},
},
})
})
}

Expand Down Expand Up @@ -121,18 +123,20 @@ func Test_RequireBelow_Prerelease_HigherCoreVersion(t *testing.T) { //nolint:par
// 1.8.0 core version. This intentionally verifies that the logic does not
// ignore the core version of the prerelease version when compared against
// the core version of the check.
r.UnitTest(t, r.TestCase{
ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){
"test": providerserver.NewProviderServer(testprovider.Provider{}),
},
TerraformVersionChecks: []tfversion.TerraformVersionCheck{
tfversion.RequireBelow(version.Must(version.NewVersion("1.8.0"))),
},
Steps: []r.TestStep{
{
Config: `//non-empty config`,
},
},
testingiface.ExpectPass(t, func(mockT *testingiface.MockT) {
r.UnitTest(mockT, r.TestCase{
ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){
"test": providerserver.NewProviderServer(testprovider.Provider{}),
},
TerraformVersionChecks: []tfversion.TerraformVersionCheck{
tfversion.RequireBelow(version.Must(version.NewVersion("1.8.0"))),
},
Steps: []r.TestStep{
{
Config: `//non-empty config`,
},
},
})
})
}

Expand All @@ -142,18 +146,20 @@ func Test_RequireBelow_Prerelease_HigherPrerelease(t *testing.T) { //nolint:para

// The 1.7.0-rc1 prerelease should always be considered to be
// below the 1.7.0-rc2 prerelease.
r.UnitTest(t, r.TestCase{
ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){
"test": providerserver.NewProviderServer(testprovider.Provider{}),
},
TerraformVersionChecks: []tfversion.TerraformVersionCheck{
tfversion.RequireBelow(version.Must(version.NewVersion("1.7.0-rc2"))),
},
Steps: []r.TestStep{
{
Config: `//non-empty config`,
},
},
testingiface.ExpectPass(t, func(mockT *testingiface.MockT) {
r.UnitTest(mockT, r.TestCase{
ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){
"test": providerserver.NewProviderServer(testprovider.Provider{}),
},
TerraformVersionChecks: []tfversion.TerraformVersionCheck{
tfversion.RequireBelow(version.Must(version.NewVersion("1.7.0-rc2"))),
},
Steps: []r.TestStep{
{
Config: `//non-empty config`,
},
},
})
})
}

Expand Down
Loading

0 comments on commit 16515b5

Please sign in to comment.