Skip to content

Commit 5121a70

Browse files
committed
Improve gomega based testing
1 parent 82228d8 commit 5121a70

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

gitlab/resource_gitlab_project_access_token_test.go

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -86,24 +86,22 @@ func testAccCheckGitlabProjectAccessTokenDoesNotExist(pat *testAccGitlabProjectA
8686
return func(s *terraform.State) error {
8787
conn := testAccProvider.Meta().(*gitlab.Client)
8888

89-
result := gomega.Eventually(func() error {
90-
tokens, _, err := conn.ProjectAccessTokens.ListProjectAccessTokens(pat.project, nil)
91-
if err != nil {
92-
return err
93-
}
94-
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))
89+
gomega.InterceptGomegaFailure(func() {
90+
gomega.Eventually(func() error {
91+
tokens, _, err := conn.ProjectAccessTokens.ListProjectAccessTokens(pat.project, nil)
92+
if err != nil {
93+
return err
9894
}
99-
}
10095

101-
return nil
102-
}).WithTimeout(time.Second * 10).WithPolling(time.Second * 2).Should(gomega.Succeed())
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))
99+
}
100+
}
103101

104-
if !result {
105-
return fmt.Errorf("Found token %d for project %s", pat.pat.ID, pat.project)
106-
}
102+
return nil
103+
}).WithTimeout(time.Second * 10).WithPolling(time.Second * 2).Should(gomega.Succeed())
104+
})
107105

108106
return nil
109107
}

0 commit comments

Comments
 (0)