Skip to content

Commit b00e6f6

Browse files
author
sfang97
committed
Call configure in provider test
1 parent c6a76fa commit b00e6f6

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

gitlab/helper_test.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package gitlab
22

33
import (
4+
"errors"
45
"fmt"
5-
"os"
6+
"strings"
67

78
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
9+
"github.com/xanzy/go-gitlab"
810
)
911

1012
// testAccCompareGitLabAttribute compares an attribute in two ResourceData's for
@@ -41,8 +43,16 @@ func testAccIsSkippedAttribute(needle string, haystack []string) bool {
4143
// Returns true if the acceptance test is running Gitlab EE.
4244
// Meant to be used as SkipFunc to skip tests that work only on Gitlab CE.
4345
func isRunningInEE() (bool, error) {
44-
if v := os.Getenv("GITLAB_LICENSE_FILE"); len(v) > 0 {
45-
return true, nil
46+
if conn, ok := testAccProvider.Meta().(*gitlab.Client); ok {
47+
version, _, err := conn.Version.GetVersion()
48+
if err != nil {
49+
return false, err
50+
}
51+
if strings.Contains(version.String(), "-ee") {
52+
return true, nil
53+
}
54+
} else {
55+
return false, errors.New("Provider not initialized, unable to get GitLab connection")
4656
}
4757
return false, nil
4858
}

gitlab/provider_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ var testAccProvider *schema.Provider
1313

1414
func init() {
1515
testAccProvider = Provider().(*schema.Provider)
16+
if err := testAccProvider.Configure(&terraform.ResourceConfig{}); err != nil {
17+
panic(err)
18+
}
1619
testAccProviders = map[string]terraform.ResourceProvider{
1720
"gitlab": testAccProvider,
1821
}

0 commit comments

Comments
 (0)