Skip to content

Commit 777d110

Browse files
chore: migrate to terraform-plugin-testing (#687)
* chore: migrate to terraform-plugin-testing It gets pretty messy trying to mix `terraform-plugin-testing` with the older `terraform-plugin-sdk` testing framework, so let's just use `terraform-plugin-testing` for both the old resources as well as the new ones. Signed-off-by: Blake Pettersson <[email protected]> * chore: ignore fields Signed-off-by: Blake Pettersson <[email protected]> --------- Signed-off-by: Blake Pettersson <[email protected]>
1 parent 1eb1cac commit 777d110

11 files changed

+53
-39
lines changed

.golangci.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ linters:
77
- containedctx
88
- contextcheck
99
- copyloopvar
10+
- depguard
1011
- dogsled
1112
- durationcheck
1213
- errcheck
@@ -33,6 +34,16 @@ linters:
3334
- whitespace
3435
- wsl
3536
settings:
37+
depguard:
38+
rules:
39+
main:
40+
deny:
41+
- pkg: github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest
42+
desc: "Use github.com/hashicorp/terraform-plugin-testing/helper/acctest instead"
43+
- pkg: github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource
44+
desc: "Use github.com/hashicorp/terraform-plugin-testing/helper/resource instead"
45+
- pkg: github.com/hashicorp/terraform-plugin-sdk/v2/terraform
46+
desc: "Use github.com/hashicorp/terraform-plugin-testing/terraform instead"
3647
dogsled:
3748
max-blank-identifiers: 3
3849
errcheck:

argocd/provider_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import (
88
"github.com/Masterminds/semver/v3"
99
"github.com/argoproj-labs/terraform-provider-argocd/internal/features"
1010
"github.com/argoproj-labs/terraform-provider-argocd/internal/testhelpers"
11-
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
12-
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
1311
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
12+
"github.com/hashicorp/terraform-plugin-testing/helper/acctest"
13+
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
1414
)
1515

1616
var testAccProviders map[string]func() (*schema.Provider, error)

argocd/resource_argocd_account_token_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"testing"
88
"time"
99

10-
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
10+
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
1111
"github.com/stretchr/testify/assert"
1212
)
1313

argocd/resource_argocd_application_set_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import (
77
"testing"
88

99
"github.com/argoproj-labs/terraform-provider-argocd/internal/features"
10-
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
11-
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
10+
"github.com/hashicorp/terraform-plugin-testing/helper/acctest"
11+
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
1212
)
1313

1414
func TestAccArgoCDApplicationSet_clusters(t *testing.T) {
@@ -436,7 +436,7 @@ func TestAccArgoCDApplicationSet_merge(t *testing.T) {
436436
ResourceName: "argocd_application_set.merge",
437437
ImportState: true,
438438
ImportStateVerify: true,
439-
ImportStateVerifyIgnore: []string{"metadata.0.resource_version"},
439+
ImportStateVerifyIgnore: []string{"metadata.0.resource_version", "spec.0.template.0.spec.0.source.0.helm.0.parameter.0.force_string", "spec.0.template.0.spec.0.source.0.helm.0.parameter.1.force_string"},
440440
},
441441
},
442442
})
@@ -482,7 +482,7 @@ func TestAccArgoCDApplicationSet_mergeNested(t *testing.T) {
482482
ResourceName: "argocd_application_set.merge_nested",
483483
ImportState: true,
484484
ImportStateVerify: true,
485-
ImportStateVerifyIgnore: []string{"metadata.0.resource_version"},
485+
ImportStateVerifyIgnore: []string{"metadata.0.resource_version", "spec.0.template.0.spec.0.source.0.helm.0.parameter.0.force_string", "spec.0.template.0.spec.0.source.0.helm.0.parameter.1.force_string"},
486486
},
487487
},
488488
})
@@ -729,7 +729,7 @@ func TestAccArgoCDApplicationSet_pullRequestBitbucketServer(t *testing.T) {
729729
ResourceName: "argocd_application_set.pr_bitbucket_server",
730730
ImportState: true,
731731
ImportStateVerify: true,
732-
ImportStateVerifyIgnore: []string{"metadata.0.resource_version"},
732+
ImportStateVerifyIgnore: []string{"metadata.0.resource_version", "spec.0.template.0.spec.0.source.0.helm.0.parameter.0.force_string"},
733733
},
734734
},
735735
})
@@ -758,7 +758,7 @@ func TestAccArgoCDApplicationSet_pullRequestGitea(t *testing.T) {
758758
ResourceName: "argocd_application_set.pr_gitea",
759759
ImportState: true,
760760
ImportStateVerify: true,
761-
ImportStateVerifyIgnore: []string{"metadata.0.resource_version"},
761+
ImportStateVerifyIgnore: []string{"metadata.0.resource_version", "spec.0.template.0.spec.0.source.0.helm.0.parameter.0.force_string"},
762762
},
763763
},
764764
})
@@ -792,7 +792,7 @@ func TestAccArgoCDApplicationSet_pullRequestGithub(t *testing.T) {
792792
ResourceName: "argocd_application_set.pr_github",
793793
ImportState: true,
794794
ImportStateVerify: true,
795-
ImportStateVerifyIgnore: []string{"metadata.0.resource_version"},
795+
ImportStateVerifyIgnore: []string{"metadata.0.resource_version", "spec.0.template.0.spec.0.source.0.helm.0.parameter.0.force_string"},
796796
},
797797
},
798798
})
@@ -826,7 +826,7 @@ func TestAccArgoCDApplicationSet_pullRequestGitlab(t *testing.T) {
826826
ResourceName: "argocd_application_set.pr_gitlab",
827827
ImportState: true,
828828
ImportStateVerify: true,
829-
ImportStateVerifyIgnore: []string{"metadata.0.resource_version"},
829+
ImportStateVerifyIgnore: []string{"metadata.0.resource_version", "spec.0.template.0.spec.0.source.0.helm.0.parameter.0.force_string"},
830830
},
831831
},
832832
})
@@ -1065,7 +1065,7 @@ func TestAccArgoCDApplicationSet_CustomNamespace(t *testing.T) {
10651065
ResourceName: "argocd_application_set.custom_namespace",
10661066
ImportState: true,
10671067
ImportStateVerify: true,
1068-
ImportStateVerifyIgnore: []string{"wait", "cascade", "status", "validate"},
1068+
ImportStateVerifyIgnore: []string{"wait", "cascade", "status", "validate", "metadata.0.resource_version", "spec.0.template.0.spec.0.source.0.helm.0.parameter.0.force_string", "spec.0.template.0.spec.0.source.0.helm.0.parameter.1.force_string"},
10691069
},
10701070
},
10711071
})

argocd/resource_argocd_application_test.go

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import (
77
"testing"
88

99
"github.com/argoproj-labs/terraform-provider-argocd/internal/features"
10-
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
11-
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
10+
"github.com/hashicorp/terraform-plugin-testing/helper/acctest"
11+
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
1212
)
1313

1414
func TestAccArgoCDApplication(t *testing.T) {
@@ -40,7 +40,7 @@ func TestAccArgoCDApplication(t *testing.T) {
4040
ResourceName: "argocd_application." + name,
4141
ImportState: true,
4242
ImportStateVerify: true,
43-
ImportStateVerifyIgnore: []string{"wait", "cascade", "metadata.0.generation", "metadata.0.resource_version", "status", "validate"},
43+
ImportStateVerifyIgnore: []string{"wait", "cascade", "metadata.0.generation", "metadata.0.resource_version", "status", "validate", "spec.0.source.0.helm.0.parameter.0.force_string"},
4444
},
4545
{
4646
// Update
@@ -154,7 +154,7 @@ ingress:
154154
ResourceName: "argocd_application.helm",
155155
ImportState: true,
156156
ImportStateVerify: true,
157-
ImportStateVerifyIgnore: []string{"wait", "cascade", "metadata.0.generation", "metadata.0.resource_version", "status", "validate"},
157+
ImportStateVerifyIgnore: []string{"wait", "cascade", "metadata.0.generation", "metadata.0.resource_version", "status", "validate", "spec.0.source.0.helm.0.parameter.0.force_string", "spec.0.source.0.helm.0.parameter.1.force_string"},
158158
},
159159
},
160160
})
@@ -304,7 +304,7 @@ func TestAccArgoCDApplication_IgnoreDifferences(t *testing.T) {
304304
ResourceName: "argocd_application.ignore_differences",
305305
ImportState: true,
306306
ImportStateVerify: true,
307-
ImportStateVerifyIgnore: []string{"wait", "cascade", "status", "validate"},
307+
ImportStateVerifyIgnore: []string{"wait", "cascade", "status", "validate", "metadata.0.generation", "metadata.0.resource_version"},
308308
},
309309
{
310310
Config: testAccArgoCDApplicationIgnoreDiffJQPathExpressions(
@@ -330,7 +330,7 @@ func TestAccArgoCDApplication_IgnoreDifferences(t *testing.T) {
330330
ResourceName: "argocd_application.ignore_differences_jqpe",
331331
ImportState: true,
332332
ImportStateVerify: true,
333-
ImportStateVerifyIgnore: []string{"wait", "cascade", "status", "validate"},
333+
ImportStateVerifyIgnore: []string{"wait", "cascade", "status", "validate", "metadata.0.generation", "metadata.0.resource_version"},
334334
},
335335
{
336336
Config: testAccArgoCDApplicationIgnoreDiffManagedFieldsManagers(
@@ -356,7 +356,7 @@ func TestAccArgoCDApplication_IgnoreDifferences(t *testing.T) {
356356
ResourceName: "argocd_application.ignore_differences_managed_fields_managers",
357357
ImportState: true,
358358
ImportStateVerify: true,
359-
ImportStateVerifyIgnore: []string{"wait", "cascade", "status", "validate"},
359+
ImportStateVerifyIgnore: []string{"wait", "cascade", "status", "validate", "metadata.0.generation", "metadata.0.resource_version"},
360360
},
361361
},
362362
})
@@ -390,7 +390,7 @@ func TestAccArgoCDApplication_RevisionHistoryLimit(t *testing.T) {
390390
ResourceName: "argocd_application.revision_history_limit",
391391
ImportState: true,
392392
ImportStateVerify: true,
393-
ImportStateVerifyIgnore: []string{"wait", "cascade", "status", "validate"},
393+
ImportStateVerifyIgnore: []string{"wait", "cascade", "status", "validate", "metadata.0.generation", "metadata.0.resource_version", "spec.0.source.0.helm.0.parameter.0.force_string", "spec.0.source.0.helm.0.parameter.1.force_string"},
394394
},
395395
},
396396
})
@@ -419,7 +419,7 @@ func TestAccArgoCDApplication_OptionalDestinationNamespace(t *testing.T) {
419419
ResourceName: "argocd_application.no_namespace",
420420
ImportState: true,
421421
ImportStateVerify: true,
422-
ImportStateVerifyIgnore: []string{"wait", "cascade", "status", "validate"},
422+
ImportStateVerifyIgnore: []string{"wait", "cascade", "status", "validate", "metadata.0.generation", "metadata.0.resource_version"},
423423
},
424424
},
425425
})
@@ -1054,7 +1054,7 @@ func TestAccArgoCDApplication_CustomNamespace(t *testing.T) {
10541054
ResourceName: "argocd_application.custom_namespace",
10551055
ImportState: true,
10561056
ImportStateVerify: true,
1057-
ImportStateVerifyIgnore: []string{"wait", "cascade", "status", "validate"},
1057+
ImportStateVerifyIgnore: []string{"wait", "cascade", "status", "validate", "metadata.0.generation", "metadata.0.resource_version", "spec.0.source.0.helm.0.parameter.0.force_string", "spec.0.source.0.helm.0.parameter.1.force_string"},
10581058
},
10591059
},
10601060
})
@@ -1099,10 +1099,13 @@ func TestAccArgoCDApplication_MultipleSources(t *testing.T) {
10991099
),
11001100
},
11011101
{
1102-
ResourceName: "argocd_application.multiple_sources",
1103-
ImportState: true,
1104-
ImportStateVerify: true,
1105-
ImportStateVerifyIgnore: []string{"wait", "cascade", "metadata.0.generation", "metadata.0.resource_version", "status", "validate"},
1102+
ResourceName: "argocd_application.multiple_sources",
1103+
ImportState: true,
1104+
ImportStateVerify: true,
1105+
ImportStateVerifyIgnore: []string{"wait", "cascade", "metadata.0.generation", "metadata.0.resource_version", "status", "validate",
1106+
"spec.0.source.0.helm.0.parameter.0.force_string",
1107+
"spec.0.source.0.helm.0.parameter.1.force_string",
1108+
"spec.0.source.0.helm.0.parameter.2.force_string"},
11061109
},
11071110
},
11081111
})
@@ -1177,7 +1180,7 @@ func TestAccArgoCDApplication_ManagedNamespaceMetadata(t *testing.T) {
11771180
ResourceName: "argocd_application.namespace_metadata",
11781181
ImportState: true,
11791182
ImportStateVerify: true,
1180-
ImportStateVerifyIgnore: []string{"wait", "cascade", "metadata.0.generation", "metadata.0.resource_version", "validate"},
1183+
ImportStateVerifyIgnore: []string{"wait", "cascade", "metadata.0.generation", "metadata.0.resource_version", "validate", "status"},
11811184
},
11821185
},
11831186
})

argocd/resource_argocd_cluster_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import (
1414
"github.com/argoproj-labs/terraform-provider-argocd/internal/testhelpers"
1515
"github.com/argoproj/argo-cd/v3/pkg/apiclient/cluster"
1616
"github.com/hashicorp/terraform-plugin-framework/types"
17-
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
18-
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
17+
"github.com/hashicorp/terraform-plugin-testing/helper/acctest"
18+
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
1919
"k8s.io/client-go/rest"
2020
"k8s.io/client-go/tools/clientcmd"
2121
"k8s.io/client-go/util/homedir"

argocd/resource_argocd_project_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import (
66
"testing"
77

88
"github.com/argoproj-labs/terraform-provider-argocd/internal/features"
9-
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
10-
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
9+
"github.com/hashicorp/terraform-plugin-testing/helper/acctest"
10+
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
1111
)
1212

1313
func TestAccArgoCDProject(t *testing.T) {

argocd/resource_argocd_project_token_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import (
77
"testing"
88
"time"
99

10-
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
11-
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
10+
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
11+
"github.com/hashicorp/terraform-plugin-testing/terraform"
1212
"github.com/stretchr/testify/assert"
1313
)
1414

argocd/resource_argocd_repository_certificate_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import (
1010
"testing"
1111

1212
"github.com/argoproj-labs/terraform-provider-argocd/internal/testhelpers"
13-
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
14-
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
13+
"github.com/hashicorp/terraform-plugin-testing/helper/acctest"
14+
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
1515
"github.com/stretchr/testify/assert"
1616
)
1717

argocd/resource_argocd_repository_credentials_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"fmt"
99
"testing"
1010

11-
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
11+
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
1212
"github.com/stretchr/testify/assert"
1313
)
1414

0 commit comments

Comments
 (0)