@@ -3,14 +3,15 @@ package provider
3
3
import (
4
4
"errors"
5
5
"fmt"
6
+ "testing"
7
+
6
8
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
7
9
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
8
10
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
9
11
gitlab "github.com/xanzy/go-gitlab"
10
- "testing"
11
12
)
12
13
13
- func TestAccGitlabTag_basic (t * testing.T ) {
14
+ func TestAccGitlabProjectTag_basic (t * testing.T ) {
14
15
testAccCheck (t )
15
16
var tag gitlab.Tag
16
17
var tag2 gitlab.Tag
@@ -21,19 +22,19 @@ func TestAccGitlabTag_basic(t *testing.T) {
21
22
resource .Test (t , resource.TestCase {
22
23
PreCheck : func () { testAccPreCheck (t ) },
23
24
ProviderFactories : providerFactories ,
24
- CheckDestroy : testAccCheckGitlabTagDestroy ,
25
+ CheckDestroy : testAccCheckGitlabProjectTagDestroy ,
25
26
Steps : []resource.TestStep {
26
27
{
27
- Config : testAccGitlabTagConfig (rInt , rInt2 , project .PathWithNamespace , branches [0 ].Name ),
28
+ Config : testAccGitlabProjectTagConfig (rInt , rInt2 , project .PathWithNamespace , branches [0 ].Name ),
28
29
Check : resource .ComposeTestCheckFunc (
29
- testAccCheckGitlabTagExists ("foo" , & tag , rInt ),
30
- testAccCheckGitlabTagExists ("foo2" , & tag2 , rInt2 ),
31
- testAccCheckGitlabTagAttributes ("foo" , & tag , & testAccGitlabTagExpectedAttributes {
30
+ testAccCheckGitlabProjectTagExists ("foo" , & tag , rInt ),
31
+ testAccCheckGitlabProjectTagExists ("foo2" , & tag2 , rInt2 ),
32
+ testAccCheckGitlabProjectTagAttributes ("foo" , & tag , & testAccGitlabProjectTagExpectedAttributes {
32
33
Name : fmt .Sprintf ("tag-%d" , rInt ),
33
34
Message : "" ,
34
35
Ref : "main" ,
35
36
}),
36
- testAccCheckGitlabTagAttributes ("foo2" , & tag2 , & testAccGitlabTagExpectedAttributes {
37
+ testAccCheckGitlabProjectTagAttributes ("foo2" , & tag2 , & testAccGitlabProjectTagExpectedAttributes {
37
38
Name : fmt .Sprintf ("tag-%d" , rInt2 ),
38
39
Message : fmt .Sprintf ("tag-%d" , rInt2 ),
39
40
Ref : branches [0 ].Name ,
@@ -49,10 +50,10 @@ func TestAccGitlabTag_basic(t *testing.T) {
49
50
},
50
51
// update properties in resource
51
52
{
52
- Config : testAccGitlabTagConfig (rInt , rInt3 , project .PathWithNamespace , branches [0 ].Name ),
53
+ Config : testAccGitlabProjectTagConfig (rInt , rInt3 , project .PathWithNamespace , branches [0 ].Name ),
53
54
Check : resource .ComposeTestCheckFunc (
54
- testAccCheckGitlabTagExists ("foo2" , & tag2 , rInt3 ),
55
- testAccCheckGitlabTagAttributes ("foo2" , & tag2 , & testAccGitlabTagExpectedAttributes {
55
+ testAccCheckGitlabProjectTagExists ("foo2" , & tag2 , rInt3 ),
56
+ testAccCheckGitlabProjectTagAttributes ("foo2" , & tag2 , & testAccGitlabProjectTagExpectedAttributes {
56
57
Name : fmt .Sprintf ("tag-%d" , rInt3 ),
57
58
Message : fmt .Sprintf ("tag-%d" , rInt3 ),
58
59
Ref : branches [0 ].Name ,
@@ -63,7 +64,7 @@ func TestAccGitlabTag_basic(t *testing.T) {
63
64
})
64
65
}
65
66
66
- func testAccCheckGitlabTagDestroy (s * terraform.State ) error {
67
+ func testAccCheckGitlabProjectTagDestroy (s * terraform.State ) error {
67
68
for _ , rs := range s .RootModule ().Resources {
68
69
if rs .Type != "gitlab_project_tag" {
69
70
continue
@@ -82,7 +83,7 @@ func testAccCheckGitlabTagDestroy(s *terraform.State) error {
82
83
return nil
83
84
}
84
85
85
- func testAccCheckGitlabTagAttributes (n string , tag * gitlab.Tag , want * testAccGitlabTagExpectedAttributes ) resource.TestCheckFunc {
86
+ func testAccCheckGitlabProjectTagAttributes (n string , tag * gitlab.Tag , want * testAccGitlabProjectTagExpectedAttributes ) resource.TestCheckFunc {
86
87
return func (s * terraform.State ) error {
87
88
rs := s .RootModule ().Resources [fmt .Sprintf ("gitlab_project_tag.%s" , n )]
88
89
ref := rs .Primary .Attributes ["ref" ]
@@ -113,7 +114,7 @@ func testAccCheckGitlabTagAttributes(n string, tag *gitlab.Tag, want *testAccGit
113
114
}
114
115
}
115
116
116
- func testAccCheckGitlabTagExists (n string , tag * gitlab.Tag , rInt int ) resource.TestCheckFunc {
117
+ func testAccCheckGitlabProjectTagExists (n string , tag * gitlab.Tag , rInt int ) resource.TestCheckFunc {
117
118
return func (s * terraform.State ) error {
118
119
rs , ok := s .RootModule ().Resources [fmt .Sprintf ("gitlab_project_tag.%s" , n )]
119
120
if ! ok {
@@ -132,7 +133,7 @@ func testAccCheckGitlabTagExists(n string, tag *gitlab.Tag, rInt int) resource.T
132
133
}
133
134
}
134
135
135
- func testAccGitlabTagConfig (rInt int , rInt2 int , project string , branch string ) string {
136
+ func testAccGitlabProjectTagConfig (rInt int , rInt2 int , project string , branch string ) string {
136
137
return fmt .Sprintf (`
137
138
resource "gitlab_project_tag" "foo" {
138
139
name = "tag-%[1]d"
@@ -148,7 +149,7 @@ func testAccGitlabTagConfig(rInt int, rInt2 int, project string, branch string)
148
149
` , rInt , rInt2 , project , branch )
149
150
}
150
151
151
- type testAccGitlabTagExpectedAttributes struct {
152
+ type testAccGitlabProjectTagExpectedAttributes struct {
152
153
Name string
153
154
Message string
154
155
Ref string
0 commit comments