-
-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix tests, update go-sentry, add sweepers
- Loading branch information
Showing
7 changed files
with
159 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package provider | ||
|
||
import ( | ||
"context" | ||
"log" | ||
"strings" | ||
|
||
"github.com/hashicorp/terraform-plugin-testing/helper/resource" | ||
"github.com/jianyuan/go-sentry/v2/sentry" | ||
"github.com/jianyuan/terraform-provider-sentry/internal/acctest" | ||
) | ||
|
||
func init() { | ||
resource.AddTestSweepers("sentry_dashboard", &resource.Sweeper{ | ||
Name: "sentry_dashboard", | ||
F: func(r string) error { | ||
ctx := context.Background() | ||
|
||
listParams := &sentry.ListCursorParams{} | ||
|
||
for { | ||
dashboards, resp, err := acctest.SharedClient.Dashboards.List(ctx, acctest.TestOrganization, listParams) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
for _, dashboard := range dashboards { | ||
if !strings.HasPrefix(sentry.StringValue(dashboard.Title), "tf-dashboard") { | ||
continue | ||
} | ||
|
||
log.Printf("[INFO] Destroying Dashboard %q", sentry.StringValue(dashboard.Title)) | ||
|
||
_, err := acctest.SharedClient.Dashboards.Delete(ctx, acctest.TestOrganization, sentry.StringValue(dashboard.ID)) | ||
if err != nil { | ||
log.Printf("[ERROR] Failed to destroy Dashboard %q: %s", sentry.StringValue(dashboard.Title), err) | ||
continue | ||
} | ||
|
||
log.Printf("[INFO] Dashboard %q has been destroyed.", sentry.StringValue(dashboard.Title)) | ||
} | ||
|
||
if resp.Cursor == "" { | ||
break | ||
} | ||
listParams.Cursor = resp.Cursor | ||
} | ||
|
||
return nil | ||
}, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package provider | ||
|
||
import ( | ||
"context" | ||
"log" | ||
"strings" | ||
|
||
"github.com/hashicorp/terraform-plugin-testing/helper/resource" | ||
"github.com/jianyuan/go-sentry/v2/sentry" | ||
"github.com/jianyuan/terraform-provider-sentry/internal/acctest" | ||
) | ||
|
||
func init() { | ||
resource.AddTestSweepers("sentry_project", &resource.Sweeper{ | ||
Name: "sentry_project", | ||
F: func(r string) error { | ||
ctx := context.Background() | ||
|
||
listParams := &sentry.ListCursorParams{} | ||
|
||
for { | ||
projects, resp, err := acctest.SharedClient.Projects.List(ctx, listParams) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
for _, project := range projects { | ||
if !strings.HasPrefix(project.Slug, "tf-project") { | ||
continue | ||
} | ||
|
||
log.Printf("[INFO] Destroying Project: %s", project.Slug) | ||
|
||
_, err := acctest.SharedClient.Projects.Delete(ctx, acctest.TestOrganization, project.Slug) | ||
if err != nil { | ||
log.Printf("[ERROR] Failed to destroy Project %q: %s", project.Slug, err) | ||
continue | ||
} | ||
|
||
log.Printf("[INFO] Project %q has been destroyed.", project.Slug) | ||
} | ||
|
||
if resp.Cursor == "" { | ||
break | ||
} | ||
listParams.Cursor = resp.Cursor | ||
} | ||
|
||
return nil | ||
}, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package provider | ||
|
||
import ( | ||
"context" | ||
"log" | ||
"strings" | ||
|
||
"github.com/hashicorp/terraform-plugin-testing/helper/resource" | ||
"github.com/jianyuan/go-sentry/v2/sentry" | ||
"github.com/jianyuan/terraform-provider-sentry/internal/acctest" | ||
) | ||
|
||
func init() { | ||
resource.AddTestSweepers("sentry_team", &resource.Sweeper{ | ||
Name: "sentry_team", | ||
F: func(r string) error { | ||
ctx := context.Background() | ||
|
||
teams, _, err := acctest.SharedClient.Teams.List(ctx, acctest.TestOrganization) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
for _, team := range teams { | ||
if !strings.HasPrefix(sentry.StringValue(team.Slug), "tf-team") { | ||
continue | ||
} | ||
|
||
log.Printf("[INFO] Destroying Team: %s", sentry.StringValue(team.Slug)) | ||
|
||
_, err := acctest.SharedClient.Teams.Delete(ctx, acctest.TestOrganization, sentry.StringValue(team.Slug)) | ||
if err != nil { | ||
log.Printf("[ERROR] Failed to destroy Team %q: %s", sentry.StringValue(team.Slug), err) | ||
continue | ||
} | ||
|
||
log.Printf("[INFO] Team %q has been destroyed.", sentry.StringValue(team.Slug)) | ||
} | ||
|
||
return nil | ||
}, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters