Skip to content

Commit 82228d8

Browse files
committed
Fix review comments
1 parent 80040ed commit 82228d8

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

gitlab/resource_gitlab_project_access_token.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,11 @@ func resourceGitlabProjectAccessTokenRead(ctx context.Context, d *schema.Resourc
157157
d.Set("created_at", projectAccessToken.CreatedAt.String())
158158
d.Set("revoked", projectAccessToken.Revoked)
159159
d.Set("user_id", projectAccessToken.UserID)
160-
d.Set("scopes", projectAccessToken.Scopes) // lintignore: R004,XR004 // TODO: Resolve this tfproviderlint issue
160+
161+
err = d.Set("scopes", projectAccessToken.Scopes)
162+
if err != nil {
163+
return diag.FromErr(err)
164+
}
161165

162166
return nil
163167
}

gitlab/resource_gitlab_project_access_token_test.go

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
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/terraform"
12+
"github.com/onsi/gomega"
1213
gitlab "github.com/xanzy/go-gitlab"
1314
)
1415

@@ -85,18 +86,23 @@ func testAccCheckGitlabProjectAccessTokenDoesNotExist(pat *testAccGitlabProjectA
8586
return func(s *terraform.State) error {
8687
conn := testAccProvider.Meta().(*gitlab.Client)
8788

88-
//Unfortunately we need to wait a bit, since the API call doesn't wait to destroy the PAT and returns immediately
89-
time.Sleep(3 * time.Second) // lintignore: R018 // TODO: Resolve this tfproviderlint issue
90-
91-
tokens, _, err := conn.ProjectAccessTokens.ListProjectAccessTokens(pat.project, nil)
92-
if err != nil {
93-
return err
94-
}
89+
result := gomega.Eventually(func() error {
90+
tokens, _, err := conn.ProjectAccessTokens.ListProjectAccessTokens(pat.project, nil)
91+
if err != nil {
92+
return err
93+
}
9594

96-
for _, token := range tokens {
97-
if token.ID == pat.pat.ID {
98-
return fmt.Errorf("Found token %d for project %s (tokens found: %d)", token.ID, pat.project, len(tokens))
95+
for _, token := range tokens {
96+
if token.ID == pat.pat.ID {
97+
return fmt.Errorf("Found token %d for project %s (tokens found: %d)", token.ID, pat.project, len(tokens))
98+
}
9999
}
100+
101+
return nil
102+
}).WithTimeout(time.Second * 10).WithPolling(time.Second * 2).Should(gomega.Succeed())
103+
104+
if !result {
105+
return fmt.Errorf("Found token %d for project %s", pat.pat.ID, pat.project)
100106
}
101107

102108
return nil

0 commit comments

Comments
 (0)