@@ -5,10 +5,11 @@ import (
55 "os"
66 "testing"
77
8- "github.com/Masterminds/semver"
8+ "github.com/Masterminds/semver/v3 "
99 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
1010 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
1111 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
12+ "github.com/oboukili/terraform-provider-argocd/internal/features"
1213)
1314
1415var testAccProviders map [string ]func () (* schema.Provider , error )
@@ -68,7 +69,7 @@ func testAccPreCheck(t *testing.T) {
6869}
6970
7071// Skip test if feature is not supported
71- func testAccPreCheckFeatureSupported (t * testing.T , feature int ) {
72+ func testAccPreCheckFeatureSupported (t * testing.T , feature features. Feature ) {
7273 v := os .Getenv ("ARGOCD_VERSION" )
7374 if v == "" {
7475 t .Skip ("ARGOCD_VERSION must be set set for feature supported acceptance tests" )
@@ -79,34 +80,35 @@ func testAccPreCheckFeatureSupported(t *testing.T, feature int) {
7980 t .Fatalf ("could not parse ARGOCD_VERSION as semantic version: %s" , v )
8081 }
8182
82- versionConstraint , ok := featureVersionConstraintsMap [feature ]
83+ fc , ok := features . ConstraintsMap [feature ]
8384 if ! ok {
8485 t .Fatal ("feature constraint is not handled by the provider" )
8586 }
8687
87- if i := versionConstraint .Compare (serverVersion ); i == 1 {
88+ if i := fc . MinVersion .Compare (serverVersion ); i == 1 {
8889 t .Skipf ("version %s does not support feature" , v )
8990 }
9091}
9192
9293// Skip test if feature is supported
93- func testAccPreCheckFeatureNotSupported (t * testing.T , feature int ) {
94- v := os .Getenv ("ARGOCD_VERSION" )
95- if v == "" {
96- t .Skip ("ARGOCD_VERSION must be set set for feature supported acceptance tests" )
97- }
98-
99- serverVersion , err := semver .NewVersion (v )
100- if err != nil {
101- t .Fatalf ("could not parse ARGOCD_VERSION as semantic version: %s" , v )
102- }
103-
104- versionConstraint , ok := featureVersionConstraintsMap [feature ]
105- if ! ok {
106- t .Fatal ("feature constraint is not handled by the provider" )
107- }
108-
109- if i := versionConstraint .Compare (serverVersion ); i != 1 {
110- t .Skipf ("not running test if feature is already supported (%s)" , v )
111- }
112- }
94+ // Note: unused at present but left in the code in case it is needed again in future
95+ // func testAccPreCheckFeatureNotSupported(t *testing.T, feature int) {
96+ // v := os.Getenv("ARGOCD_VERSION")
97+ // if v == "" {
98+ // t.Skip("ARGOCD_VERSION must be set set for feature supported acceptance tests")
99+ // }
100+
101+ // serverVersion, err := semver.NewVersion(v)
102+ // if err != nil {
103+ // t.Fatalf("could not parse ARGOCD_VERSION as semantic version: %s", v)
104+ // }
105+
106+ // versionConstraint, ok := featureVersionConstraintsMap[feature]
107+ // if !ok {
108+ // t.Fatal("feature constraint is not handled by the provider")
109+ // }
110+
111+ // if i := versionConstraint.Compare(serverVersion); i != 1 {
112+ // t.Skipf("not running test if feature is already supported (%s)", v)
113+ // }
114+ // }
0 commit comments