|
9 | 9 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
|
10 | 10 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
|
11 | 11 | "github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
|
| 12 | + "github.com/onsi/gomega" |
12 | 13 | gitlab "github.com/xanzy/go-gitlab"
|
13 | 14 | )
|
14 | 15 |
|
@@ -85,18 +86,23 @@ func testAccCheckGitlabProjectAccessTokenDoesNotExist(pat *testAccGitlabProjectA
|
85 | 86 | return func(s *terraform.State) error {
|
86 | 87 | conn := testAccProvider.Meta().(*gitlab.Client)
|
87 | 88 |
|
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 | + } |
95 | 94 |
|
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 | + } |
99 | 99 | }
|
| 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) |
100 | 106 | }
|
101 | 107 |
|
102 | 108 | return nil
|
|
0 commit comments